And Also Operator

The AndAlso operator is used to evaluate two expressions but evaluates the second expression only if the first expression is True. For example, if you want to access a property of a Bookmark object only if the bookmark exists (thus avoiding an error), you can use the AndAlso statement, as shown in Listing 4.7. This technique is often referred to as short circuiting.

Listing 4.7. Using the AndAlso operator

If Bookmark1 IsNot Nothing AndAlso Bookmark1.Bold Then

MsgBox("The bookmark text is bold") End If

0 0

Post a comment