IsNumber
This routine was designed to act as a numbers-only mask for any TextBox Keypress event. Simply call it from any KeyPress event and feed it the KeyAscii return value.
Original Author: Matthew Inman
Inputs
AsciiCode - This is the ascii code of the character to be tested.
Assumptions
HOW TO CALL:
In the KeyPress event of Text1 (just an example), all you need is
If Not IsNumber(KeyAscii) then KeyAscii=0
and the text box will accept only numbers from the user while allowing them to use BACKSPACE.
Returns
Returns TRUE if the ascii code was of a numeric character OR backspace (saves time...you'll see), FALSE if not.
API Declarations
Code
Function IsNumber (ByVal KeyAscii As Integer) As Integer
If InStr(1, "1234567890", Chr$(KeyAscii), 0) > 0 Or KeyAscii = 8 Then
IsNumber = True
Else
IsNumber = False
End If
End Function
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.