While...Wend Statement
When a program encounters a While statement, it tests the condition. If the condition is False, the program continues directly following the Wend statement. If the condition is True, the loop is executed until the program finds Wend and then jumps back to the While statement. If the condition is still True, the loop is executed again.
Unlike the Do...Loop statement, you cannot cancel a While...Wend loop with Exit. Never exit a While...Wend loop with GoTo, since this can cause a run-time error.
O uso de Do...Loop é máis flexíbel que While...Wend.
Sintaxe:
While Condición [Instrución] Wend
Exemplo:
Sub ExemploWhileWend
Dim sTexto As String
Dim iExec As Integer
sTexto ="Isto é un texto curto"
iExec = 1
while iRun < Len(sTexto)
if Mid(sTexto,iExec,1 )<> " " then Mid( sTexto ,iExec, 1, Chr( 1 + Asc( Mid(sTexto,iExec,1 )) )
iRun = iRun + 1
Wend
MsgBox sTexto,0,"Texto codificado"
End Sub