Private Sub text1_KeyPress(KeyAscii As Integer)
If Not IsNumeric(text1.Text & Chr(KeyAscii)) And Not KeyAscii = 8 Then KeyAscii = 0
if (KeyAscii>=43) and (KeyAscii<=46) Then KeyAscii = 0
'it ignores '-', '+', '.' and ','
End Sub
Private Sub txtReceiptID_KeyPress(KeyAscii As Integer)
Dim Keychar As String
If KeyAscii > 31 Then
Keychar = Chr(KeyAscii)
If Not IsNumeric(Keychar) Then
KeyAscii = 0
End If
End If
i usually use this code:
The following may be used for whole numbers:
I used this code in my project:
End Sub
Try this code: