Hello Euvin,
An operators are (same as in math) +, -, *, /, =.
There are some additional operators you might need which are "And",
"Or", "AndAlso", "OrElse" and "&".
Example (math):
Dim Variable As Integer 'Here the value is automatically assigned to 0.
Variable = 1 + 2
"Variable" will contain the value 3.
Example "And":
Dim Variable1 As Boolean = True
Dim Variable2 As Boolean = False
Dim Result As Boolean
Result = Variable1 And Variable2
"Result" will be False. It can only be True if both Variable1 AND
Variable2 are True.
The truth table is like this:
Variable1 Variable2 Result
False False False
True False False
False True False
True True True
Example "Or":
Dim Variable1 As Boolean = True
Dim Variable2 As Boolean = False
Dim Result As Boolean
Result = Variable1 Or Variable2
"Result" will be True, if either Variable1 OR Variable2 is True.
The truth table is like this:
Variable1 Variable2 Result
False False False
True False True
False True True
True True True
"AndAlso" and "OrElse" are also "And" and "Or" operators, but with a
difference:
AndAlso will only check the next value if the first one matched the
criterion. If it does not, the next values will not be evaluated.
Dim Value1 As Integer = 1
Dim Value2 As Integer = 2
If Value1 = 1 AndAlso Value2 = 2 Then
MsgBox ("Match")
'Will be shown.
End If
Dim Value3 As Integer = 3
If Value2 = 3 AndAlso Value3 = 3 Then
MsgBox ("Match")
'Will not be shown
End If
You could replace the AndAlso operator with this:
If Value2 = 3 Then
If Value3 = 3 Then
MsgBox("Match")
End If
End If
OrElse does exactly the opposite: If a value does not match, it will
check the next value.
Dim Value1 As Integer = 1
Dim Value2 As Integer = 2
If Value1 =3 OrElse Value2 = 2 Then
MsgBox("Match")
'Will be shown
End If
Best regards,
Martin
Am 13.04.2008 07:17, schrieb Euvin:
What is an operator? Could you give me an example of an operator?
Anyone!