Table 7.1: Conditional Operators
Operator | Meaning |
= | Equal to |
> | More than |
< | Less Than |
>= | More than and equal |
<= | Less than and equal |
<> | Not Equal to |
* You can also compare strings with the above operators. However, there are
certain rules to follows: Upper case letters are less than lowercase letters,
"A"<"B"<"C"<"D".......<"Z"
and number are less than letters.
Table 7.2
Operator | Meaning |
And | Both sides must be true |
or | One side or other must be true |
Xor | One side or other must be true but not both |
Not | Negates truth |
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)For more example on If...Then...Else, Click on the [Sample1] and[sample2] program here.
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 IfEnd Sub