Directives

9.1 Use If…Then…Else when the decision is based on one condition being True or False.

If…Then is well suited for making a decision based on the evaluation of a single condition, and it’s the most commonly used decision construct. If…Then has the following syntax:

							If 
							condition 
							Then 
							statement
						

or

							If 
							condition 
							Then
   [statements]
End If
						

If condition evaluates to True, the statement or statements are executed. If condition evaluates to False, the statement or statements are not executed. Expressions can be simple or complex. Regardless of complexity, the expression used for condition must evaluate to True or False. For instance, all the following expressions are valid for condition.

 sngCoordinate >= 8 strFirstName = "Adam" ...

Get Practical Standards for Microsoft® Visual Basic® .NET, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.