Note Unlike Cbased languages the VB 2008 token is used to denote both assignment and equality semantics therefore VB 2008 does not supply a operator

In addition, you may build a complex expression to test within a flow-control construct using the code conditional operators (also known as the logical operators) listed in Table 3-9. This table outlines the most common conditional operators of the language.

Table 3-9. VB 2008 Conditional Operators

VB 2008 Conditional

Operator Example Meaning in Life

Table 3-9. VB 2008 Conditional Operators

And

If age = 30 And name = "Fred" Then

Conditional AND operator, where both conditions must be True for the condition to be True

AndAlso

If age = 30 AndAlso name = "Fred" Then

Conditional AND operator that supports short-circuiting, meaning if the first expression is False, the second expression is not evaluated

Or

If age = 30 Or name = "Fred" Then

Conditional OR operator

OrElse

If age = 30 OrElse name = "Fred" Then

Conditional OR operator that supports short-circuiting, meaning if either expression is True, True is returned

Not

If Not myBool Then

Conditional NOT operator

As I am assuming you have prior experience in BASIC or C-based languages, I won't belabor the use of these operators. If you require additional details beyond the following code snippet, I will assume you will consult the .NET Framework 3.5 SDK documentation. However, here is a simple example:

Sub Main() Dim userOption As String Dim userAge As Integer

Was this article helpful?

0 0

Post a comment