DECISION STATEMENTSINVB.NET<br />
Introduction <br />Decision making statements in VB.NET are used to control the flow of a program by checking one or more ...
If .. then<br />This statement is used to test a condition and execute a set of statements if the condition is true . If i...
syntax<br />If Condition Then    One or more Visual Basic statementsEnd If<br />
Example<br />Dim mark as integer<br />If mark>40 then<br />Msgbox (“Pass”)<br />End if<br />
If … then … else<br />This statement is used to test a condition and execute a set of statements if the condition is true ...
Syntax<br />If condition Then  One or more statementsElse  One or more statementsEndIf<br />
Example <br />Dim a AsIntegerDim b AsIntegera = 3b = 4If a > b Then    MsgBox("a is greater then b")Else    MsgBox("b is g...
Select case statement<br />The Select Case statement executes one of several groups of statements depending on the value o...
Syntax <br />Select Case expression    Case value1         Statement 1    Case value2         Statement 2   Case value3   ...
Example <br />' Examination Grades Dim grade AsStringPrivateSub Compute_Click()    grade= txtgrade.Text    Select Case gra...
The End.<br />… Thank u…<br />
Upcoming SlideShare
Loading in …5
×

Decision statements in vb.net

5,782 views
5,575 views

Published on

Published in: Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,782
On SlideShare
0
From Embeds
0
Number of Embeds
126
Actions
Shares
0
Downloads
137
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Decision statements in vb.net

  1. 1. DECISION STATEMENTSINVB.NET<br />
  2. 2. Introduction <br />Decision making statements in VB.NET are used to control the flow of a program by checking one or more conditions. There are 3 types, They are<br />If … then<br />If …. Then … else<br />Select case<br />
  3. 3. If .. then<br />This statement is used to test a condition and execute a set of statements if the condition is true . If it is false, the statement which is next to the if … then structure is executed.<br />
  4. 4. syntax<br />If Condition Then    One or more Visual Basic statementsEnd If<br />
  5. 5. Example<br />Dim mark as integer<br />If mark>40 then<br />Msgbox (“Pass”)<br />End if<br />
  6. 6. If … then … else<br />This statement is used to test a condition and execute a set of statements if the condition is true and execute another set of statement if it is false.<br />
  7. 7. Syntax<br />If condition Then  One or more statementsElse  One or more statementsEndIf<br />
  8. 8. Example <br />Dim a AsIntegerDim b AsIntegera = 3b = 4If a > b Then    MsgBox("a is greater then b")Else    MsgBox("b is greater then a")EndIf<br />
  9. 9. Select case statement<br />The Select Case statement executes one of several groups of statements depending on the value of an expression. If your code has the capability to handle different values of a particular variable then you can use a Select Case statement. You use Select Case to test an expression, determine which of the given cases it matches and execute the code in that matched case. <br />
  10. 10. Syntax <br />Select Case expression    Case value1         Statement 1    Case value2         Statement 2   Case value3       Statement 3    Case value4         .         .         .    CaseElse        StatementEnd Select<br />
  11. 11. Example <br />' Examination Grades Dim grade AsStringPrivateSub Compute_Click()    grade= txtgrade.Text    Select Case grade       Case  "A"           result.Caption="High Distinction"      Case"A-"          result.Caption="Distinction"      Case"B"            result.Caption="Credit"      Case"C"            result.Caption="Pass"      CaseElse            result.Caption="Fail"      End Select EndSub<br />
  12. 12. The End.<br />… Thank u…<br />

×