Code for Loops
A. For next ...Loop :-
Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 10
Print i
Next i
End Sub
Dim i As Integer
For i = 1 To 10
Print i
Next i
End Sub
B. Do while.....Loop
Private Sub Command2_Click()
Dim i As Integer
i = 1
Do While i <= 10
Print i
i = i + 1
Loop
Dim i As Integer
i = 1
Do While i <= 10
Print i
i = i + 1
Loop
End Sub
C. Do until....Loop
Private Sub Command3_Click()Dim i As Integer
i = 10
Do While i >= 1
Print i
i = i - 1
Loop
End Sub
D. Do...Loop While
Private Sub Command4_Click()
Dim i As Integer
i = 1
Do
Print i
i = i + 1
Loop While i <= 10
Dim i As Integer
i = 1
Do
Print i
i = i + 1
Loop While i <= 10
End Sub
E. Do....until Loop
Private Sub Command5_Click()
Dim i As Integer
i = 10
Do
Print i
i = i - 1
Loop While i >= 1
End Sub
Dim i As Integer
i = 10
Do
Print i
i = i - 1
Loop While i >= 1
End Sub
F. While...Wend
Private Sub Command6_Click()
Dim i As Integer
i = 1
While i <= 10
Print i
i = i + 1
Wend
End Sub.
Dim i As Integer
i = 1
While i <= 10
Print i
i = i + 1
Wend
End Sub.
No comments:
Post a Comment