Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do While loop with multiple conditions. 2

Status
Not open for further replies.

tmcnutt

Programmer
Joined
May 17, 2002
Messages
83
Location
US
I have the following loop that will not exit when I test for multiple conditions. Here is the code
Do
Result = (InputBox("ESF or HSC (E or H)", "Select type of pump", "E"))
Loop While Result <> ("E" Or "H")

I have tried additional loop test variations such as
Loop While Result <> "E" or Result <> "H"

If I use only test case instead of two, it works okay.
I do no know what I am missing. Any help would be greatly appreciated.

Thanks,
Tom
 
I changed the "or" to "and" and it works, but it doesn't make sense to me. Can someone explain or show me how to use the "or"?
 
This is DeMorgan's Theorem.

Basically, these are equivalent:
Code:
  C = NOT A OR NOT B

  C = NOT (A AND B)

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks for the responses and the code sample. I changed my code to John's recommendation and it worked fine.
 
John,

I changed it to "OrElse" and I remember reading about that and "AndAlso"for short circuiting. Using "Or" or "And", did it always evaluate all conditions regardless?

Thanks,
Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top