|
-
Nov 2nd, 1999, 11:32 PM
#1
Thread Starter
New Member
How do you make it so that you can type backspace in a textbox after you've limited the textbox to only numbers.
Thanks
-
Nov 3rd, 1999, 01:33 AM
#2
Frenzied Member
Use the keypress method on the field in qustion to run the following (the second if statement should be modified if you don't want the user to enter "," or "." characters)
Code:
If KeyAscii< Asc("0") Or KeyAscii> Asc("9") Then
If KeyAscii = Asc(",") Or KeyAscii = Asc(".") Or KeyAscii = 8 Then
'nothing, we will allow these characters
Else 'the user has pressed some key other than 0-9 or "," or "." or backspace
KeyAscii = 0 ' cancel the character
field.SelStart = 0
field.SelLength = Len(field)
Beep
End If
End If
-
Nov 3rd, 1999, 04:02 AM
#3
Hyperactive Member
Look into the MaxLength property also.
------------------
Tom Young, 14 Year Old
[email protected]
ICQ: 15743470
AIM: TomY10
PERL, JavaScript and VB Programmer
-
Nov 3rd, 1999, 10:01 AM
#4
Addicted Member
Try this Function. Credit goes to Aaron Young
[/code]
Function Num_Bksp_Only(ByVal KeyAscii As Integer) As Integer
If KeyAscii = vbKeyBack Or IsNumeric(Chr(KeyAscii)) Then
Num_Bksp_Only = KeyAscii
End If
End Function
[code]
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
|