Understanding If Statements
For many decisions, you may want to execute a statement (or group of statements) only if a particular condition is True. Two forms of the If statement handle True conditions: the single-line If statement and the multiple-line If statement. Each uses the If statement to check a condition. If the condition is True, the program runs the commands associated with the If statement. For example, the following two If statements perform the same function:
'Single-Line IF If x > 5 then x = 0 'Multiple-Line IF If x > 5 Then x = 0 End If
In the code sample, the condition is the value of the variable x being greater than 5. If this condition is True the statement x=0 will be executed. If the condition is False (in the preceding ...
Get Special Edition Using Microsoft® Visual Basic® .NET 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.