-
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
-
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
-
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
-
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:
(###) ###-####