Legal Information |
|
To effectively control the VB program flow, we shall use If...Then...Else statement together with the conditonal operators and logical operators. The general format for the if...then...else statement is
If conditions Then* any If..Then..Else statement must end with End If. Sometime it is not necessary to use Else.
VB expressions
Else
VB expressions
End If
Example:
Private Sub OK_Click()
firstnum = Val(usernum1.Text)
secondnum = Val(usernum2.Text)
total = Val(sum.Text)
If total = firstnum + secondnum And Val(sum.Text) <> 0 Then
correct.Visible = True
wrong.Visible = False
Else
correct.Visible = False
wrong.Visible = True
End If
End Sub
Search Knowledge Base | Feedback |