Results 1 to 2 of 2

Thread: Msgbox not appearing

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    12

    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:
    1. Private Sub CommandButton1_Click()
    2.     '6 combinations of valid postcodes AN, AAN, ANN, AANN, ANA, AANA
    3.    If Not Text1.Text Like "[A-Z][0-9] [A-Z][A-Z][A-Z]" Then
    4.      If Not Text1.Text Like "[A-Z][A-Z][0-9] [A-Z][A-Z][A-Z]" Then
    5.          If Not Text1.Text Like "[A-Z][0-9][0-9] [A-Z][A-Z][A-Z]" Then
    6.             If Not Text1.Text Like "[A-Z][A-Z][0-9][0-9] [A-Z][A-Z][A-Z]" Then
    7.                 If Not Text1.Text Like "[A-Z][0-9][A-Z] [A-Z][A-Z][A-Z]" Then
    8.                     If Not Text1.Text Like "[A-Z][A-Z][0-9][A-Z] [A-Z][A-Z][A-Z]" Then
    9.                       Call MsgBox("Invalid Postcode, please re-enter.", vbExclamation, "Error")
    10.                          Text1.SetFocus
    11.                             Else
    12.                              MsgBox "The Postcode you have entered is """ & Text1.Text & """"
    13.                           Exit Sub
    14.                     End If
    15.                 End If
    16.             End If
    17.         End If
    18.     End If
    19.   End If
    20. End Sub
    Last edited by RobDog888; Mar 18th, 2005 at 02:35 PM. Reason: Added vbcode tags

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Msgbox not appearing

    VB Code:
    1. dim strCode as string
    2.  
    3. strcode = Textbox1.Text
    4.  
    5. Select Case strcode
    6.    case "AN", "AAN", "ANN", "AANN", "ANA, "AANA"
    7.       msgbox "OK"
    8.    case else
    9.       msgbox "Not OK"
    10. 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
  •  



Click Here to Expand Forum to Full Width