|
-
Jul 16th, 2000, 04:03 AM
#1
Thread Starter
New Member
ok i have a textbox that the user is filling a phone number in it .
i want to block writing letters and if im writing :
if isnumeric(txtphone)= false then
msgbox "incorrect number"
else
endif
but i cant write ( - ) to separate the areacode from the number :
954 - 65823154 what can i do without putting an extra textbox for the areacode?
thanks
-
Jul 16th, 2000, 04:28 AM
#2
Fanatic Member
That's the onlt thing you can do, add anothe text box...b/c (to my knowledge) a dash a considered a letter so you will have to enable letters in order to have them. OR you can make it so after 3 digits are typed in, enable letters and when a dash (-) is placed, redisable them...it's more havoc than adding another text box but if you want to take that path...
Gl,
D!m
-
Jul 16th, 2000, 05:06 AM
#3
Lively Member
I tend to you the keypress for that text box and something like
if keyascii = 32 then
else
if keyascii = 45 then
Else
if keyascii = 8 then
Else
If (KeyAscii > 47) And (KeyAscii < 58) Then ' check to make sure a number has been pressed
Else
MsgBox ("Numbers only please")
KeyAscii = 0
End If
End if
End if
End if
the keyascii for space is 32 and i think the the keyascii for - is 45.
keyascii for backspace = 8
I hope this makes sense. I am new to VB but finmd that this works for me
nuts
if at first you don't succeed, drink the rest of the bottle and loop to the same place tomorrow
-
Jul 16th, 2000, 08:38 AM
#4
Instead of a regular textbox, you can use the Masked Edit Control. (You get it in your toolbox by going to Project -> Components and checking "Microsoft Masked Edit Control 6.0".)
To do the phone number thing, you can set the control's Mask property to:
(###) ###-####
"It's cold gin time again ..."
Check out my website here.
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
|