Minggu, 25 November 2012

Fungsi Perulangan pada VB Net

Bentuk desain :


Source code :

Public Class Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim x As Integer
        ListBox1.Items.Clear()
        For x = 10 To 1 Step -1
            ListBox1.Items.Add(x)
        Next
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim x As Integer
        ListBox2.Items.Clear()
        x = 10
        Do While x >= 1
            ListBox2.Items.Add(x)
            x = x - 1
        Loop
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim x As Integer
        ListBox3.Items.Clear()
        x = 10
        Do Until x = 0
            ListBox3.Items.Add(x)
            x = x - 1
        Loop
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim x As Integer
        ListBox4.Items.Clear()
        x = 10
        While x >= 10
            ListBox4.Items.Add("HORAS")
            x = x - 1
        End While
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        End
    End Sub
End Class

Semoga bermanfaat...

Tidak ada komentar:

Posting Komentar