|
-
Oct 9th, 2000, 07:36 AM
#1
Is there a function that validates that the user has typed letters and not numbers? I have an input box and i need that the user types only numbers.
-
Oct 9th, 2000, 07:52 AM
#2
Lively Member
This code will help you if it's just a plain text box.
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Don't know how to get it right if it's an InputBox function you are talking about here...
D
-
Oct 9th, 2000, 07:56 AM
#3
Lively Member
If KeyAscii > 48 And KeyAscii < 57 Then
KeyAscii = 0
End If
Inverted...
D
-
Oct 9th, 2000, 10:22 AM
#4
New Member
If your using a text box then then checking the keyascii will work fine. If your using an inputbox, then you will need to do something like this
Code:
Dim strNumber as string
do until IsNumeric(strNumber) = True
strNumber = InputBox("Enter A Number")
'To Display A Message
If Not IsNumeric(strNumber) Then msgbox("That is not a number")
loop
'Do Something with the number
Terry
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|