chitika

Tuesday, September 20, 2011

vb: how to use do loop, for loop, while loop, exit loop?

This site provides users with the information about vb, visual basic, vb6, do loop, for loop, while loop, how to use do loop, how to use for loop, how to use while loop, exit loop, do until, while wend, for, next, for loop step, example, and more.

If you think that this site is helpful, please recommend your friends to visit our site.


How to use do loop, for loop, while loop, exit loop in vb?

The following is the code for using do loop, for loop, while loop, exit loop in vb:

1. do until ... loop and do while ... loop


--------------------------------------------------------------------------------
Dim ct As Integer

Do Until ct = 10
ct = ct + 1
If (ct = 8) Then
Exit Do
end if
Loop

Do while ct < 10
ct = ct + 1
If (ct = 8) Then
Exit Do
end if
Loop

--------------------------------------------------------------------------------

2. While... Wend loop

--------------------------------------------------------------------------------
Dim no As Integer

no = 1
While no <=100
no = no + 1
if(no=50)then
Exit While
end if
Wend
--------------------------------------------------------------------------------

3. for ... next loop

--------------------------------------------------------------------------------
Dim i As Integer

For i = 0 To 15
if (i=8)then
exit for
end if
Next i

For I = 10 To 0 Step -2
Debug.Print I
Next I

Note:

"Step -2": For-Next loop is decremented by 2 each time through the loop.

No comments:

Post a Comment

For other hundreds of computer repair tips, tricks, tweaks, guide, help, please go to


http://website.edusoftmax.com