VB.Net Forum

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


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

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



1 Answer Found

Answer #1    Answered By: Shruti Sharma     Answered On: Jan 21

break and continue are available in vb.net

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

Check out this url

For loop in vb.net

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

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.