if

Sub Main()
    Dim variable AS Boolean
    variable = True

    If variable Then
        Debug.Print "value"
    End If
End Sub
実行結果
value

if-else

Sub Main()
    Dim variable AS Boolean
    variable = False

    If variable Then
        Debug.Print "True"
    Else
        Debug.Print "False"
    End If
End Sub
実行結果
False

if-else

Sub Main()
    Dim variable As Integer
    variable = 2

    If variable = 1 Then
        Debug.Print "1"
    ElseIf variable = 2 Then
        Debug.Print "2"
    Else
        Debug.Print "Else"
    End If
End Sub
実行結果
2

Select-Case

Sub Main()
    Dim variable As Integer
    variable = 2

    Dim result As Integer

    Select Case variable
    Case 1
        result = 1
    Case 2
        result = 2
    Case 3
        result = 3
    Case Else
        result = 99
    End Select

    Debug.Print result
End Sub

実行結果

2

複数条件のSelect Case

Sub Main()
    Dim value AS Integer
    value = 4

    Select Case value
        Case 1, 2, 3
            Debug.Print "1, 2, 3"
        Case 4, 5, 6
            Debug.Print "4, 5, 6"
        Case Else
            Debug.Print "Else"
    End Select
End Sub
実行結果
4, 5, 6

数値の範囲でSelect Case

Sub Main()
    Dim value AS Integer
    value = 5

    Select Case value
        Case 1 To 3
            Debug.Print "1~3"
        Case 4 TO 6
            Debug.Print "4~6"
        Case Else
            Debug.Print "Else"
    End Select
End Sub
実行結果
4~6

Select Case Is

Sub Main()
    Dim value AS Integer
    value = 6

    Select Case value
        Case Is <= 5
            Debug.Print "<=5"
        Case Is <= 10
            Debug.Print "<=10"
        Case Else
            Debug.Print "10<"
    End Select
End Sub
実行結果
<=10