What is the equivalent for keyword 'break' in VB.NET

4 Answers

0 votes
Exit For 


Exit While 


Exit Do

 



answered May 9, 2016 by avibootz
0 votes
Imports System
				
Public Module Module1
	Public Sub Main()
		Dim index As Integer = 0
		
		Do While index <= 50
			If index > 10 Then
				Exit Do
			End If

			Console.Write(index & " ")
			index += 1
		Loop
			
	End Sub
End Module
	
	
	

' run:
'
' 0 1 2 3 4 5 6 7 8 9 10
'

 



answered Jun 18, 2023 by avibootz
edited Jun 18, 2023 by avibootz
0 votes
Imports System
                 
Public Module Module1
    Public Sub Main()
        Dim index As Integer = 0
		
        While index < 50
            Console.Write(index.ToString & " ") 
            If index = 13 Then
                Exit While
            End If
            index += 1
        End While
			
    End Sub
End Module
     
     
     
 
' run:
'
' 0 1 2 3 4 5 6 7 8 9 10 11 12 13
'

 



answered Jun 18, 2023 by avibootz
0 votes
Imports System
                 
Public Module Module1
    Public Sub Main()
		
    	For i As Integer = 1 To 10  
            Console.Write(i & " ")
            If i = 5 Then  
                Exit For 
            End If  
		Next
			
    End Sub
End Module
     
     
     
 
' run:
'
' 1 2 3 4 5
'

 



answered Jun 18, 2023 by avibootz

Related questions

1 answer 74 views
1 answer 192 views
2 answers 182 views
1 answer 154 views
154 views asked Jun 25, 2022 by avibootz
1 answer 196 views
1 answer 215 views
...