by Dr. Dre (1 Submission)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Fri 9th June 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Simple code allows print into the TextBox numbers only.
API Declarations
Public Sub NUMBERS_ONLY(KeyAscii As Integer, TXT As TextBox)
Select Case KeyAscii
'negotive numbers
'KeyAscii; 45 is "-"
Case 45
If Len(TXT.Text) >= 1 Then
KeyAscii = 0
End If
'KeyAscii; 8 is "Backspace", 46 is "." decimal,
' 48-57 is "0-9"
Case 8, 46, 48 To 57
KeyAscii = KeyAscii
Case Else
KeyAscii = 0
End Select
End Sub
'on KeyPress event:
Private Sub Text1_KeyPress(KeyAscii As Integer)
NUMBERS_ONLY KeyAscii, Text1
End Sub