Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    hamilton,ontario
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow VB help with loop

    Here is a bit of the code I'm working with.

    Do While LCase(strType) <> "c" Or LCase(strType) <> "p"
    MsgBox ("Please Enter Correct Customer Type")
    strType = InputBox("Please Enter Customer Type, Either C or P")
    Loop


    Thing is no matter what I type in I get stuck in the loop.

    I need it to check what the user has inputed and if it's anything but c or p then they will get an error message and prompted to enter the data again.
    whittys.com
    Nomsane?
    That is all

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Logic error:

    Code:
    Do While LCase(strType) <> "c" AND LCase(strType) <> "p" 
    MsgBox ("Please Enter Correct Customer Type") 
    strType = InputBox("Please Enter Customer Type, Either C or P") 
    Loop
    You always have at least one of the two conditions returning false which means with the OR in there the loop is always going to be executed. You need the AND to exit the loop if one of the conditions isn't false.

  • #3
    New Coder
    Join Date
    Jun 2002
    Location
    hamilton,ontario
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ahhh thats why. Thanks a lot.
    I didn't even catch that bit.
    whittys.com
    Nomsane?
    That is all


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •