18/09/07 18:23
SuperTiz
ciao GrG, probabilmente la mia risposta ti sarà inutile lol, però potresti usare questo semplicissimo codice :
Private Sub Text1_Change()
Dim Char As String
Char = Right(Text1.Text, 1)
If Char <> "1" And Char <> "2" And Char <> "3" And Char <> "4" And Char <> "5" And Char <> "6" And Char <> "7" And Char <> "8" And Char <> "9" And Char <> "0" And Char <> "," And Char <> "-" Then
Text1.Text = ""
End If
End Sub
in questo modo la tua textbox accetta tutti i numeri dallo 0 al 9, la virgola e il segno meno. puoi aggiungere qualsiasi carattere da "accettare" semplicemente aggiungendo "And Char <> "carattere da accettare" prima del "then"
cosi devi evitare di prevedere il codice ascii del carattere che vuoi accettare
spero che ti sia utile
ciaoo
edit : soltanto che se uno torna indietro col puntatore puo mettere tutti i caratteri che vuole lol
come non detto XDXD
Ultima modifica effettuata da SuperTiz 18/09/07 18:28
aaa
18/09/07 20:23
gantonio
Veramente basta una riga
If InStr("0123456789-+.,", Chr$(KeyAscii)) = 0 Then keyascii=0
nell'evento KeyPress
aaa
01/05/11 15:13
fineagles
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii <> 8 And KeyAscii <> 44 Then
If KeyAscii > 57 Or KeyAscii < 48 Then
KeyAscii = 0
End If
End If
End Sub
aaa