Jumat, 28 Desember 2012

Contoh Program Perulangan (Looping)

Artikel -20

Contoh Program Perulangan (Looping)

·         Do-Loop
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim halaman As Byte
        halaman = 1
        Do While halaman <= 10
            ListBox1.Items.Add(halaman)
            halaman = halaman + 1
        Loop
    End Sub
End Class
·         For-Next
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   Dim halaman As Byte
   For halaman = 1 To 10
       ComboBox1.Items.Add(halaman)

   Next
End Sub
End Class
While –End While
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim halaman As Byte
        halaman = 1
        While halaman <= 10
            ComboBox1.Items.Add(halaman)
            halaman = halaman + 1
        End While
    End Sub
End Class

Tidak ada komentar:

Poskan Komentar