Hi I need some help with a loop
I want a random number to be generated that is not equal to 3 different, and previously defined variables.
The loop I have is like this one below
Help with Code Tags
VB.NET Syntax (Toggle Plain Text)
1. random = randomNum.next(0, 10)
2. while random = first or second or third
3. random = randomNum.next(0, 10)
4. end while
random = randomNum.next(0, 10) while random = first or second or third random = randomNum.next(0, 10) end while
first, second, and third are previously defined short integers that have different values.
I thought this would work however my program gets stuck in an endless loop =(
How do I define more than one requirement for a while loop? Apparently or isn't working for me
Need loop help (beginner)
Started by harrisdefth, Oct 22 2009 11:31 AM
1 reply to this topic
#2
Posted 22 October 2009 - 05:12 PM
You probably need to write:
While (Random = First) Or (Random = Second) Or (Random = Third)
The parentheses probably aren't strictly necessary, but they help readability. Anyway, the problem is that the things on each side of an "Or" or "And" have to be fully formed conditions. Even though in English you can say something like "equals first, or second, or third", programming languages don't work that way.
While (Random = First) Or (Random = Second) Or (Random = Third)
The parentheses probably aren't strictly necessary, but they help readability. Anyway, the problem is that the things on each side of an "Or" or "And" have to be fully formed conditions. Even though in English you can say something like "equals first, or second, or third", programming languages don't work that way.
reedbeta.com - developer blog, OpenGL demos, and other projects
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











