Zebra0.com

visual-basic loops

A FOR loop allows you to specify a starting value for a variable, an end value, and the amount you want to change, or increment. The first format does not specify an increment: it will increment by +1:
For <variable> = <start value> to <end value>
<statements>
Next <variable>

Using the example below modify the code to print each of the sequences below:

5,6,7,8

-5, -4, -3, -2, -1, 0

 

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.ListBox1.Sorted = False
        For num As Integer = 0 To 5
            Me.ListBox1.Items.Add(num)
        Next
    End Sub
End Class

NEXT: For Loops