In This tutorial I will going to discuss the basic use if "IF Statement" in visual basic programming.
IF statement is one of the powerful statement in visual basic programming, it allows the programmer to make a condition whether the system or program do an action.
This is the correct syntax on how to use this statement..
Note: Before you write this code, remove the [] to avoid program crash or errors.
If condition [ Then ] [ statements ][ ElseIf elseifcondition [ Then ] [ elseifstatements ] ][ Else [ elsestatements ] ]End If
' Single-line syntax:If condition Then[ statements ] [ Else [ elsestatements ] ]
According to support.microsoft.com it Conditionally executes a group of statements, depending on the value of an expression.
Credits to mdsn.microsoft.com
Required. Expression. Must evaluate to True or False, or to a data type that is implicitly convertible toBoolean.
If the expression is a Nullable Boolean variable that evaluates to Nothing, the condition is treated as if the expression is not True, and the Else block is executed.
Required in the single-line syntax; optional in the multiple-line syntax.
Optional. One or more statements following If...Then that are executed if condition evaluates to True.
Required if ElseIf is present. Expression. Must evaluate to True or False, or to a data type that is implicitly convertible to Boolean.
Optional. One or more statements following ElseIf...Then that are executed if elseifcondition evaluates toTrue.
Optional. One or more statements that are executed if no previous condition or elseifcondition expression evaluates to True.
Terminates the If...Then...Else block.
No comments:
Post a Comment