|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
[VB] Togliere un carattere vuoto da una stringa (Formattazio
Dato la stringa: " Benvenuto Tom "
Vorrei inserire un controllo che mi toglie gli spazi vuoti e mi sostituisce con quello che voglio, in questo caso con un " _ " , e quindi la frase diventa: " Benvenuto_Tom " come si fa??? |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Feb 2000
Città: Frittole
Messaggi: 2596
|
stringa="Buongiorno Tom"
stringa_new=Replace(stringa," ","_") Bye !!
__________________
Ryzen7 5800x ASUS Prime B550 Plus GTX 1660 Super Muletto: Athlon64 3000+ @2750mhz Ciuchino: intel 80286 @8mhz ram 384kb video ega msdos3.1 floppy 5-1/4 hd 10mb. |
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
OK grazie,
Come si fa per sapere se la parola " Gatto " e' un Integer oppure una stringa ??? |
|
|
|
|
|
#4 | |
|
Member
Iscritto dal: Jan 2001
Città: PATAVIUM
Messaggi: 280
|
Quote:
msgbox "Gatto è una parola come diavolo fa a essere un numero",vbinformation else msgbox " "Gatto" non è una variabile stringa", vbcritical end if
__________________
Salva il Pianeta |
|
|
|
|
|
|
#5 | |
|
Senior Member
Iscritto dal: Feb 2001
Città: Nordest
Messaggi: 217
|
Quote:
Forse volevi dire: Codice:
Dim var As String
var = InputBox("Inserire un numero o una stringa")
If IsNumeric(var) Then
MsgBox "Il valore inserito è un numero"
Else
MsgBox "Il valore inserito è una stringa"
End If
Se il valore da inserire deve essere per forza Integer, si potrebbe forzare un cast intercettando l'errore, come fa questa funzione: Codice:
Public Function IsInteger(v As Variant) As Boolean
Dim n As Integer
Dim ret As Boolean
On Error Resume Next
n = CInt(v)
If Err.Number <> 0 Then
ret = False
Else
ret = (n = Val(v)) 'non accetta valori con decimali
End If
On Error GoTo 0
IsInteger = ret
End Function
|
|
|
|
|
|
|
#6 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
OK, grazie mille domattina lo provo, ciao!
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 00:54.



















