This will execute code while the condition is true.
Identify the three basic parts in the loops below:
Dim intLoop as Integer Dim intTriangle as Integer Dim intFactorial as Integer intLoop = 1 While intLoop <= 10 intLoop = intLoop + 1 Wend intLoop = 1 While intLoop <= intNumber 'this loop will calculate the triangle value of a number ' and the factorial value of a number intTriangle = intTriangle + intLoop intFactorial =intFactorial * intLoop intLoop = intLoop + 1 WendThe examples above are very similar to a For-Next loop, so there is no real advantage to using it. The real power of a While-Wend loop is when you don't know when the condition will be met. For example, if you are reading lines of text from a file, you don't know in advance how many lines you will read until you reach the end of the file. So, instead you test for the end of file marker:
While Not EOF(1) ' read a line from the file WendOur test is for when we reach the end of the file, that's what EOF means.