Runing Text

Do not Click

Selection

Sunday 23 August 2009 , Posted by Andi at 01:14

Conditional Selection statement or a statement requesting the computer to perform action selection based on a given condition. VB.Net syntax provides 2 options for branching action where each has his own purposes, namely:
• If Clause
If statement is a selection that is used with the consideration of a condition to do anything if the conditions are right and others may do if the condition is false. Syntax writing is

If condition then
Action if Condition True
End if



If you want to do something else if the condition is false then the syntaxnya are:

If condition then
Action if true condition
Else
Action if condition false
End if



If only support for action 2 for 1 condition, if you want to give more than 2 action could be "nested if" (if in the if). His syntax becomes:

If condition 1 then
Action if true condition 1
Else
If condition 2 then
Action if true condition 2
Else If condition 3 then
Action if condition and condition 2 false 3 true
Else
Action 3 if condition false
End if
End if



• Select case clause
Select case statement is a selection that is used with the consideration of the value of a variable or of a condition. The syntax is:

Select case variable / condition
Value Case 1: statement 1 if the value
Value Case 2: statement 2 if the value
Case 3 value: 3 value if statement
Case else
Statement if no value matched
End select


Example:

Dim q as integer = 2
Strq as string Dim
Select case q
Case 1: strq = "Bad Quality"
Case 2: strq = "Average Quality"
Case 3: strq = "Excellent Quality"
Case else
Console.writeline ( "No Such quality")
End select

Currently have 0 komentar:

Leave a Reply

Post a Comment

Related Post