|
-
Mar 18th, 2005, 11:03 AM
#1
Thread Starter
New Member
Msgbox not appearing
I am using the following code to validate the user input. It can only be in one of 6 formats as explained in the IF stmt below. If a user enters an incorrect format the Call Msgbox Invalid postcode pops up.
However the second msgbox which is called when the user enters the correct input is not working properly. As you can see there are 6 valid options, only when the user enters the last correct input (i.e. If Not Text1.Text Like "[A-Z][A-Z][0-9][A-Z] [A-Z][A-Z][A-Z]" Then) does the text msg box appear telling you what you have entered.
For the other 5 options it doesn’t do anything?
I would be very grateful if you could have a look and see why this might be.
VB Code:
Private Sub CommandButton1_Click()
'6 combinations of valid postcodes AN, AAN, ANN, AANN, ANA, AANA
If Not Text1.Text Like "[A-Z][0-9] [A-Z][A-Z][A-Z]" Then
If Not Text1.Text Like "[A-Z][A-Z][0-9] [A-Z][A-Z][A-Z]" Then
If Not Text1.Text Like "[A-Z][0-9][0-9] [A-Z][A-Z][A-Z]" Then
If Not Text1.Text Like "[A-Z][A-Z][0-9][0-9] [A-Z][A-Z][A-Z]" Then
If Not Text1.Text Like "[A-Z][0-9][A-Z] [A-Z][A-Z][A-Z]" Then
If Not Text1.Text Like "[A-Z][A-Z][0-9][A-Z] [A-Z][A-Z][A-Z]" Then
Call MsgBox("Invalid Postcode, please re-enter.", vbExclamation, "Error")
Text1.SetFocus
Else
MsgBox "The Postcode you have entered is """ & Text1.Text & """"
Exit Sub
End If
End If
End If
End If
End If
End If
End Sub
Last edited by RobDog888; Mar 18th, 2005 at 02:35 PM.
Reason: Added vbcode tags
-
Mar 18th, 2005, 12:18 PM
#2
Frenzied Member
Re: Msgbox not appearing
VB Code:
dim strCode as string
strcode = Textbox1.Text
Select Case strcode
case "AN", "AAN", "ANN", "AANN", "ANA, "AANA"
msgbox "OK"
case else
msgbox "Not OK"
end select
Tengo mas preguntas que contestas
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
|