Currently, lets say that I have this code:
While r <> "HI"
r = RandomStringGenerator(1)
time = time + 1
Console.WriteLine(r)
End While
how can I make it so that i can say basically this:
While r <> "HI" Or While r <> "BY"
r = RandomStringGenerator(1)
time = time + 1
Console.WriteLine(r)
End While
I’ve alreadly tried:
While r <> "HI" Or r <> "BY"
r = RandomStringGenerator(1)
time = time + 1
Console.WriteLine(r)
End While
But it still doesn’t work! What’s up with this?
The way you’ve written your conditional it will always be true and the loop will go infinitely.
This essentially says
This will be true for every single string in existence. It sounds like you want to continue if the string is neither “hi” or “by”. If so try the following
One minor final point is you should prefer
OrElseto plainOrandAndAlsoto plainAnd. The former versions are both short circuiting operations while the latter or not.