Conditional Branching
Unconditional branching is just calling a subroutine or function on the subsequent line.
There are several different ways you can implement conditional branching.
If - Then - Else
If (iValue > 10) Then
Call MsgBox("number is greater than 10")
Else
Call MsgBox("number is less than or equal to 10")
End If
Select - Case
Select Case sText
Case "Match 1": Call Proc1()
Case "Match 2": Call Proc2()
Case Else: Call Proc3()
End Select
Immediate IF
Dim iNumber As Integer
iNumber = 50
Call MsgBox( IIf( iNumber > 40, "over forty", "less than forty") )
Nested Conditionals
For more complex decision making and branching these can be nested.
Public Sub Example()
Dim lAge As Long
lAge = 32
If (1Age < 40) Then
Call MsgBox("less than 40")
Else
Select Case lAge
Case 100
Case 10
Case Is < 50
If (lAge > 40) Then
Else
End If
End Select
End If
End Sub
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext