I'm having trouble getting a loop to work.
I have tried Do....Loop, Do While.....Loop, Do Until.....Loop
I have not tried a For Loop because I am unsure how to write it.
Anyway....
here's what I am trying to do:
Dim PlayerLife As Integer = 1000
Dim MonsterLife As Integer = 1000
Dim PlayerDamage As Integer = 1
Dim MonsterDamage As Integer = 2
Loop
PlayerLife = PlayerLife - MonsterDamage
MonsterLife = MonsterLife - PlayerDamage
End Loop
Exit the loop when either PlayerLife or MonsterLife is < = 0.
When I tried putting these equations in the loop structures that I mentioned above that I did try, 1 of 2 things happened:
Either the program hung and froze while trying to do it OR only the first line in the loop was calculated down to 0 and the second line was ignored and remained at it's original value.
According to the numbers I have posted above, PlayerLife would reach 0 first and MonsterLife would be a value of 500.
What can I do to get this loop to work and calculate both results until one of them reaches 0?
Enter your message below
Sign in or Join us (it's free).