Contrast With Nested If
ElseIf is not a nested test as seen before, though it is similar
If txtNum.Text = 1 Then
MsgBox(“John”)
ElseIf txtNum.Text = 2 Then
MsgBox(“Paul”)
ElseIf txtNum.Text = 3 Then
MsgBox(“George”)
ElseIf txtNum.Text = 4 Then
MsgBox(“Ringo”)
Else
MsgBox(“Who?”)
End If
If txtNum.Text = 1 Then
MsgBox(“John”)
Else
If txtNum.Text = 2 Then
MsgBox(“Paul”)
Else
If txtNum.Text = 3 Then
MsgBox(“George”)
Else
If txtNum.Text = 4 Then
MsgBox(“Ringo”)
Else
MsgBox(“Who?”)
End If
End If
End If
End If
Previous slide
Next slide
Back to first slide
View graphic version