Hey guys, I have somewhere read the we shouldn't use
Do While but Do Until,
Did you know that? do you know why?
André
Printable View
Hey guys, I have somewhere read the we shouldn't use
Do While but Do Until,
Did you know that? do you know why?
André
I haven't heard that, as both constructs are useful depending on what you want to do. Maybe you read that we should shy away from the "While/Wend" construct because it only remains in the language for backwards compatibility and has been replaced by "Do While/Loop".
DO UNTIL means that you want it to do something until something else happens i.e.
that code will keep adding a 1 to the progress bar wuntil it reaches 100Code:Do
Progressbar1.value = Progressbar1.value + 1
Loop Until ProgressBar1.value = 100
DO WHILE means that you want it to do someting while something else is happening i.e.
that will add a 1 to the progress bar only if the value of the progress bar is 100Code:Do
Progressbar1.value = Progressbar1.value + 1
Loop While ProgressBar1.value = 100
I hope that you understand this
[Edited by dimava on 09-19-2000 at 06:55 AM]
I usually use Do Until.
You could also use the For..Next statement as well.Code:Do Until Progressbar1.Value = 100
Progressbar1.Value = Progressbar1.Value + 1
DoEvents
Loop
Code:For i = 0 to 100
Progressbar1.Value = i
DoEvents
Next i
Thanks, I know all of these constructions, the thing is that Bruce is close to what I read. It's an old construct to be fased out.
Thanks guys, have a great day!
André
When dealing with larger loops, using a For...Next loop is much faster than a Do...While loop.