5.4. If...Then...Else Selection Statement

As we have explained, the If...Then selection statement performs an indicated action (or sequence of actions) only when the condition evaluates to true; otherwise, the action (or sequence of actions) is skipped. The If...Then...Else selection statement allows you to specify that a different action (or sequence of actions) is to be performed when the condition is true than when the condition is false. For example, the Visual Basic statement

					If studentGrade >= 60
					Then
   Console.WriteLine("Passed")
Else
   Console.WriteLine("Failed"
					End If
				

prints "Passed" if the student’s grade is greater than or equal to 60, and prints "Failed" if the student’s grade is less than 60. In either case, after printing occurs, ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, 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.