for the "while" loop, what's the difference between "wend" and "loop", what's the function of them????
I am so confused.
Cerebrate
Printable View
for the "while" loop, what's the difference between "wend" and "loop", what's the function of them????
I am so confused.
Cerebrate
The Do...Loop is provides a more structured and flexible way of looping, for example, the Do Loop you can use While or Until and you can use the Exit Do function to exit the Loop.
The While ... Wend loop was maintained for backwards-compatibility with older versions of Basic. QBasic introduced Do While ... Loop as a replacement, and was carried over to VB. As Megatron said, "Do" is more flexible in that you can also use "Until" with it and you can use "Exit Do" to get out of it. Essentially though, the following two examples are equivalent:
Do While x <= 10
Debug.Print x
x = x + 1
Loop
While x <= 10
Debug.Print x
x = x + 1
Wend
Some more goodies about Do loop
[code]
1.
Do while condition1
Loop
'Is the same as
Do until not condition1
Loop
2.
Do
Loop while condition2
'Is the same as
Do
Loop until not condition2
[code]
And for 1. you will skip the loop whenever the condition is true
And for 2. you will exit the loop after the code been executed in it, if the condition is true