Logo 
Search:

VB.Net Answers

Ask Question   UnAnswered
Home » Forum » VB.Net       RSS Feeds
  Question Asked By: Priya Mohana   on Jan 21 In VB.Net Category.

  
Question Answered By: Shruti Sharma   on Jan 21

break and continue are available in vb.net

FYI
- break and continue are not the only way to loop through.

Check out this url
http://www.startvbdotnet.com/language/loops.aspx

For loop in vb.net


For index=start to end[Step step]
[statements]
[Exit For]
[statements]
Next[index]

The index variable is set to start automatically when the loop starts. Each time in the loop, index is incremented by step and when index equals end, the loop ends.

Example on For loop

Module Module1

Sub Main()
Dim d As Integer
For d = 0 To 2
System.Console.WriteLine("In the For Loop")
Next d
End Sub

End Module



While Loop

Example on While loop

Module Module1

Sub Main()
Dim d, e As Integer
d = 0
e = 6
While e > 4
e -= 1
d += 1
End While
System.Console.WriteLine("The Loop ran " & e & "times")
End Sub

End Module

Share: