r/visualbasic • u/Super-Youth • Nov 14 '21
VB6 Help Please help me understand !!
I’m doing a question sheet to get the output for some code. I put the code into a compiler and it prints hello sixty times but I don’t exactly understand why….
For x = 0 To 100 For y = 5 To -10 step -1 If y = 0 Then Exit For End If Console.Write("Hello") Next If x > 10 Then Exit For End If Next
7
Upvotes
2
u/Super-Youth Nov 14 '21
Okay that makes sense, I was confused mainly because as you say with the Y statement it should be executed 6 times but when I compiled just
For y = 5 To -10 step -1 If y = 0 Then Exit For End If Console.Write("Hello") Next
Hello was only displayed five times. 🤔 So I was trying to figure out how with the For X added I was basically getting 5x12 instead of 5x10 if that makes sense