Conditional Statement <ul><li>IF Condition   </li></ul><ul><li>Syntax for If Condition </li></ul><ul><li>If (Condition) Th...
If Condition & Select Case Statement <ul><li>The first line contains our condition: &quot;If the following condition is me...
Select Case Statement <ul><li>Example   </li></ul><ul><li>Imports System.Console Dim keyIn As Integer WriteLine(&quot;Ente...
Loops in VB.Net <ul><li>For LOOP </li></ul><ul><li>The For loop is the most popular loop. For loops enable us to execute a...
Loops in VB.Net <ul><li>Example on For loop  </li></ul><ul><li>Module Module1 Sub Main() Dim d As Integer For d = 0 To 2 S...
Loops in VB.Net <ul><li>Example on For loop  </li></ul><ul><li>Module Module1 Sub Main() Dim d As Integer For d = 0 To 2 S...
Loops in VB.Net <ul><li>Example for While Loop </li></ul><ul><li>‘ Imports System.Console </li></ul><ul><li>Module Module1...
Loops in VB.Net <ul><li>Do Loop  </li></ul><ul><li>The Do loop can be used to execute a fixed block of statements indefini...
Loops in VB.Net <ul><li>Example on Do loop  </li></ul><ul><li>Module Module1 Sub Main() Dim str As String Do Until str = &...
Upcoming SlideShare
Loading in...5
×

Vb (2)

1,294

Published on

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

  • Be the first to like this

No Downloads
Views
Total Views
1,294
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Vb (2)

  1. 1. Conditional Statement <ul><li>IF Condition </li></ul><ul><li>Syntax for If Condition </li></ul><ul><li>If (Condition) Then </li></ul><ul><li>Statement ………. </li></ul><ul><li>Else </li></ul><ul><li> Statement ………. </li></ul><ul><li>Example </li></ul><ul><li>Dim percentage As Integer </li></ul><ul><li>WriteLine(&quot;Enter the percentage&quot;) </li></ul><ul><li>percentage = Val(ReadLine()) </li></ul><ul><li>If percentage >= 75 Then </li></ul><ul><li>WriteLine(&quot;Qualified for sitting examination&quot;) </li></ul><ul><li>Else </li></ul><ul><li>WriteLine(&quot;Not Qualified for sitting examination&quot;) </li></ul><ul><li>End If </li></ul><ul><li>Read() </li></ul>
  2. 2. If Condition & Select Case Statement <ul><li>The first line contains our condition: &quot;If the following condition is met&quot;. </li></ul><ul><li>The second line is what we want to do if the condition is indeed met. </li></ul><ul><li>The third line tells Visual Basic that the If statement ends right here. </li></ul><ul><li>Select....Case Statement </li></ul><ul><li>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. </li></ul><ul><li>The syntax of the Select Case statement looks like this: </li></ul><ul><li>Select Case testexpression     [Case expressionlist-n         [statements-n]] . . .     [Case Else elsestatements] End Select </li></ul>
  3. 3. Select Case Statement <ul><li>Example </li></ul><ul><li>Imports System.Console Dim keyIn As Integer WriteLine(&quot;Enter a number between 1 and 4&quot;) keyIn = Val(ReadLine()) Select Case keyIn Case 1 WriteLine(&quot;You entered 1&quot;) Case 2 WriteLine(&quot;You entered 2&quot;) Case 3 WriteLine(&quot;You entered 3&quot;) Case 4 WriteLine(&quot;You entered 4&quot;) End Select </li></ul>
  4. 4. Loops in VB.Net <ul><li>For LOOP </li></ul><ul><li>The For loop is the most popular loop. For loops enable us to execute a series of expressions multiple numbers of times. The For loop in VB .NET needs a loop index which counts the number of loop iterations as the loop executes. The syntax for the For loop looks like this: </li></ul><ul><li>Syntax for FOR LOOP </li></ul><ul><li>For index=start to end[Step step] [statements] [Exit For] [statements] Next[index] </li></ul>
  5. 5. Loops in VB.Net <ul><li>Example on For loop </li></ul><ul><li>Module Module1 Sub Main() Dim d As Integer For d = 0 To 2 System.Console.WriteLine(&quot;In the For Loop&quot;) Next d End Sub End Module </li></ul><ul><li>While loop </li></ul><ul><li>While loop keeps executing until the condition against which it tests remain true. </li></ul><ul><li>The syntax of while loop looks like this: </li></ul><ul><li>While condition [statements] End While </li></ul>
  6. 6. Loops in VB.Net <ul><li>Example on For loop </li></ul><ul><li>Module Module1 Sub Main() Dim d As Integer For d = 0 To 2 System.Console.WriteLine(&quot;In the For Loop&quot;) Next d End Sub End Module </li></ul><ul><li>While loop </li></ul><ul><li>While loop keeps executing until the condition against which it tests remain true. </li></ul><ul><li>The syntax of while loop looks like this: </li></ul><ul><li>While condition [statements] End While </li></ul>
  7. 7. Loops in VB.Net <ul><li>Example for While Loop </li></ul><ul><li>‘ Imports System.Console </li></ul><ul><li>Module Module1 </li></ul><ul><li>Sub Main() </li></ul><ul><li>Dim e As Integer </li></ul><ul><li>While e <= 3 </li></ul><ul><li>e = e + 1 </li></ul><ul><li>System.Console.WriteLine(&quot;The Loop ran &quot; & e & &quot;times&quot;) </li></ul><ul><li>End While </li></ul><ul><li>Read() </li></ul><ul><li>End Sub </li></ul><ul><li>End Module </li></ul>
  8. 8. Loops in VB.Net <ul><li>Do Loop </li></ul><ul><li>The Do loop can be used to execute a fixed block of statements indefinite number of times. The Do loop keeps executing it's statements while or until the condition is true. Two keywords, while and until can be used with the do loop. The Do loop also supports an Exit Do statement which makes the loop to exit at any moment. </li></ul><ul><li>The syntax of Do loop looks like this: </li></ul><ul><li>Do[{while | Until} condition] [statements] [Exit Do] [statements] Loop </li></ul>
  9. 9. Loops in VB.Net <ul><li>Example on Do loop </li></ul><ul><li>Module Module1 Sub Main() Dim str As String Do Until str = &quot;Cool&quot; System.Console.WriteLine(&quot;What to do?&quot;) str = System.Console.ReadLine() Loop End Sub End Module </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×