Numbers in Textbox

Force textbox to accept numbers only.
Needs adjustments to work on VB6

CodeFunctionName
What is this?

Public

Not Tested

Original Work
Private Sub Text1_KeyPress(KeyAscii As Integer)
' When the user presses a key, check to insure the KeyAscii value is:
' Between 48 - Ascii 0
' 57 - Ascii 9
' 8 - BackSpace
' 46 - Ascii .
If InStr(Text1.Text, ".") And KeyAscii = 46 Then
KeyAscii = 0
Exit Sub
End If
If Not ((KeyAscii > 48 And KeyAscii < 57) Or KeyAscii = 8 Or KeyAscii = 46) Then
KeyAscii = 0 '0 is Ascii Null
End If
End Sub

Views 4,616

Downloads 1,566

CodeID
DB ID

ANmarAmdeen
608
Revisions

v1.0

Wednesday
June
6
2018