Monday, 27 February 2012

Loops in Visual Basic

Visual basic uses three types of loops. Namely:
1) For Loops
2) Do Loops
3) Enumeration Loops- For Each

For loops use an auto increment of the form:
For i=1 to 10
Avar=i & "I's increment Value is " & (i+1)
Form1.print Avar
Next i

Do While statements are loops executing when the condition is true:
i=0
Do while(i<10)
Form.print " "&i
i=i+1
Loop

Dim item as Variant
Do Until rsRecord.EOF
Form1.Print rs.Fields(0)
Loop
nArray=Array(3,6,4,2,6,7,9)
For Each item in nArray
if item>6 Then Form1.Print item
Next item

No comments:

Post a Comment