Programming & Scripting Tutorials

Visual Basic: Conditional and Logical Operators





Conditional Operators



Conditional Operators are used to compare values. Most of them aren't much use on there own but are more useful in If and Else statements (as demonstrated in the previous lesson.

There are six basic types of conditional operators in visual basic:

Equal to
More than
Less than
More than or equal to
Less that or equal to
Not equal to

They are achieved as follows:

Equal to: "="
More than: ">"
Less than: "<"
More than or equal to: ">="
Less than or equal to: "<="
Not equal to: "<>"




Logical Operators



Logical operators are also use for comparison, however logical operators are if you want to make more than one comparison. There are four main types of logical operators in visual basic:

"And" Both sides must be true
"or" One side or the other must be true
"Xor" One side or the other must be true, but not both
"Not" Is not true

You can use them in if statements like so:

If CheckBox6.Checked = True LOGICALOPERATOR CheckBox2.Checked = True Then
            'Insert stuff here
End If


This Visual Basic tutorial was written by


Back to Visual Basic

Advertisement: