Senin, 05 November 2012

Tugas 4



‘Button Isi Data
Private Sub Btisi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btisi.Click
        ListBox1.Items.Add(TextBox1.Text)
    End Sub

‘Button 1-10
Private Sub Bt1-10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt1-10Click
        Dim A As Integer
        A = 0
        Do
            A = A + 1
            ListBox1.Items.Add(A)
        Loop Until A = 10
    End Sub

 ‘Button Satu
Private Sub Btsatu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btsatu.Click
        ListBox2.Items.Add(ListBox1.SelectedItem)
    End Sub

‘Button Beberapa
Private Sub Btbeberapa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btbeberapa.Click
        Dim obj As Object
        For Each obj In ListBox1.SelectedItems
            ListBox2.Items.Add(obj)
        Next
    End Sub

‘Button Semua
Private Sub Btsemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btsemua.Click
        ListBox2.Items.AddRange(ListBox1.Items)

    End Sub

‘Button Hapus Satu
Private Sub Bthpssatu.Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bthpssatu.Click
        Dim obj As Object
        obj = ListBox2.SelectedItem
        ListBox2.Items.Remove(obj)
    End Sub

‘Button Hapus Beberapa
Private Sub Bthpsbeberapa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bthpsbeberapa.Click

        For i As Integer = 0 To ListBox2.SelectedIndices.Count - 1
            ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
        Next
    End Sub

‘Button Hapus Semua
Private Sub Bthpssemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bthpssemua.Click
        ListBox2.Items.Clear()
    End Sub

‘Button Tutup
Private Sub Bttutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bttutup.Click
        Me.Close()

    End Sub




Tidak ada komentar:

Posting Komentar