austin350s10
Active Member
- Joined
- Jul 30, 2010
- Messages
- 321
I have been working on a script to check if a user have entered a valid phone number into an InputBox. If they enter invalid information then it should keep looping until they enter valid information. Right now the following script only loops twice and lets invalid information pass through.
Any suggestions on how to fix this?
Any suggestions on how to fix this?
Code:
PNumber = Application.InputBox("Please enter the best phone number to contact you at", "Required", Type:=2)
On Error GoTo ErrorHandler
If PNumber Like "###-###-####" Then
MsgBox "Stop"
Else
ErrorHandler:
PNumber = Application.InputBox("You didn't enter your phone number correctly" & vbNewLine _
& "Please re-enter the best phone number to contact you at" & vbNewLine & vbNewLine _
& "The correct format is ###-###-####", "Required", PNumber, Type:=2)
End If
Resume Next