Control Flow Statements in VB.net

इस पोस्ट में हम VB.Net में प्रयोग होने वाले Control Flow Statements के बारे में जानेगे |

Control Flow Statements

VB.Net मे control flow statements Program के flow को control करती है। यह प्रोग्राम मे प्रयोग होने वाले डेटा को control करती हैं। यह statements दो प्रकार की होती है।

Image result for Control Flow Statements

  • Conditional Statements: VB.Net मे conditional statements का use conditions को check करने के लिए किया जाता है। यह मुख्यतः तीन प्रकार की होती है।
  • If- Then
  • If – Then – Else
  • Select Case

If- Then

if-then statement का use normal conditions check करने के लिए किया जाता है। इसमे लिखी गई condition के true होने पर If- End If block की statements execute हो जाती है। और condition false होने पर control बाहर चला जाता है।

Syntax :
If Condition Then
Statements
End If

Example :

If a > b Then


Msgbox (“A is greater”)

End If

If- Then- Else

इस conditional statement मे दो block होते है। condition के true होने पर If block execute होता है और condition के false होने पर Else block execute होता है।

Syntax :

If Condition Then
[If block Statements] Else
[Else Block Statements] End If

Example :


If a > b Then
Msgbox (“A is greater”)
Else
Msgbox (“B is greater”)
End If

Select Case

Select Case statement का use किसी expression की value को अलग अलग cases पर check करने के लिए किया जाता है। इसमे select case मे लिखी गई expression की value cases के साथ match की जाती हैं और सही match found होने पर उस block की statement execute हो जाती है। किसी case के match न होने पर Case Else की statement execute होती है।

Syntax :

Select Case textexpression
Case ExpressionList………N
[‘Statements … … N]] [Case Else
[Statement Else]] End Select

Example :

Select Case Now.DayOfWeek
Case DayOfWeek.Sunday
MsgBox(“Its Time to Enjoy”)
Case DayOfWeek.Monday
MsgBox(“Have a nice week”)
Case Else
MsgBox(“Enjoy this week”)
End Select
Select Case


error: Content is protected !!