ovrei in una form inserire un text box che accetti solo numeri ed escluda le lettere
Ho provato a seguire un manuale di Microsoft.press (visual basic.net )
Dice di inserire nell'evento keypress la seguente routine
Private Sub quantita_ingrediente_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles quantita_ingrediente.KeyPress
If Not (Char.IsDigit(e.KeyChar) Or Char.IsControl(e.KeyChar)) Then
e.Handled = True
End If
End Sub
che non mi funziona : il textbox continua ad accettare tutti i tasti, ho provato ad inserire uno stop per vedere se ci passa e ho verificato che nnn sente neppure lo stop
Private Sub quantita_ingrediente_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles quantita_ingrediente.KeyPress
Stop
If Not (Char.IsDigit(e.KeyChar) Or Char.IsControl(e.KeyChar)) Then
e.Handled = True
End If
End Sub
qualcuno mi può dare una dritta ?
grazie Paolo![]()