VB.Net Syntax


For - Next

For icount = 1 to 20  'the variable is automatically declared  

Next icount

For icount As Integer = 1 to 20 'the variable is declared on the same line

Next icount

Dim icount As Integer 'the variable is declared earlier
For icount = 1 to 20

Next icount

For icount As Integer = 20 to 1 Step -1

Next icount

For icount As Integer = 2 To 10
   If (icount = 6) Then
       Continue For
   End If
Next

For - Each

Dim objRow As System.Windows.Forms.DataGridViewRow 
For Each objRow In objDataGridView.Rows

Next objRow


Do - While - Loop

Do While (inumber < 5) 
   inumber = inumber + 1
   Exit While
Loop

Do While (inumber < 5)
   If (True) Then
      Continue While
   End If
Loop


Do - Until - Loop

Do Until (inumber = 5) 
   inumber = inumber + 1
Loop

While - End - While

While 
   Exit While
End While

VB includes an additional While-End While loop. This loop is identical to the Do-While loop.


Do - Loop - While

Do 

Loop While (inumber = 5)


Do - Loop - Until

Do 

Loop Until (inumber = 5)



© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext