Search Tools Links Login

GBIC: Conditional flow


Visual Basic 6, or VB Classic

The following is reprinted for archival purposes from Gary Beene's Information Center, with permission from Mr. Beene himself.


'VB offers 6 basic methods of flow control

1. For ... Next
2. If ... Then
3. Select Case ... End Select
4. While ... Wend
5. Do ... Loop
6. Goto

'For ... Next =================================
For i = 1 To j Step k
...
Next i

'Example
For i = 1 To 10
Print i
Next i

'If ... Then =================================
If (expression) Then
...
ElseIf (expression)
...
Else
...
End If

'Example
If j > 6 Then
Print "big"
ElseIf i <> 32
Print "hello"
Else
Print "none of the above
End If

'Select Case ... End Select =================================
Select Case (expression)
Case (variable list)
Case (variable list)
Case Else
End Select

'While ... Wend =================================
While (expression)
...
Wend

'Do ... Loop =================================
Do While | Until (expression)
...
Loop While | Until (expression)

For Each (variable) In (Collection)
Next

'Example
Do While j < 10
j = j + 1
Print J
Loop

'Example
Do
j = j + 1
Print J
Loop Until j = 25

'GoTo =================================
Goto Line

'Example
Goto Start 'skips the next two lines
j = j + 1
Print j
Start:
Print j

About this post

Posted: 2021-02-11
By: ArchiveBot
Viewed: 148 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.