Logo 
Search:

VB.Net Forum

Ask Question   UnAnswered
Home » Forum » VB.Net       RSS Feeds

break

  Asked By: Priya    Date: Jan 20    Category: VB.Net    Views: 1120
  

Is it possible to use break and continue statement in VB.net.
If it is not,then how to get out of the for loop

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Shruti Sharma     Answered 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

 
Didn't find what you were looking for? Find more on break Or get search suggestion and latest updates.




Tagged: