0

Can anyone see whats wrong with my while loop below? Basically I want to request a user to enter either "m" or "w", however, when I run it seems to enter an infinite loop despite the user entering "m" or "w".

While period <> "m" Or period <> "w"
    period = InputBox(Prompt:="Please enter the period (m/w): ", Title:="Period")
Wend
1
  • Thanks Kevin and Daniel, AND worked perfectly :D Commented Dec 18, 2013 at 21:40

2 Answers 2

3

It is an infinite loop because if period = "m" then period <> "w" and vice versa

Switching to the following is likely what you want.

While period <> "m" AND period <> "w"
    period = InputBox(Prompt:="Please enter the period (m/w): ", Title:="Period")
Wend
Sign up to request clarification or add additional context in comments.

Comments

2

I think you mean And instead of Or pretty much any input will not be 'w' or 'm' including w and m. (w is not equal to m so that conditional is still true and vice versa).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.