Rabu, 14 November 2012

Tugas Ke 4 "Listbox"

TAMPILAN AWAL



1. Button "Masukan"
 >> Kodingnya Adalah
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgsHandles Button1.Click
        If TextBox1.Text <> "" Then
            ListBox1.Items.Add(TextBox1.Text)
        Else
            MsgBox("Harus Input Data", vbInformation, "Peringatan")
        End If
        TextBox1.Focus()
        TextBox1.Clear()
      End Sub
  2.  Button "1 - 10"
>> Kodingnya Adalah
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim Angka As Integer
        For Angka = 1 To 10
            ListBox1.Items.Add(Angka)
        Next
     End Sub
3. Button "Copy Satu"
>> Kodingnya Adalah
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If ListBox1.Items.Count = 0 Then
            MsgBox("Data Belum Dipilih", vbInformation, "Informasi")
        Else
            ListBox2.Items.Add(ListBox1.SelectedItem)
        End If
     End Sub
 4. Button "Copy Beberapa"
>> Kodingnya Adalah
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If ListBox1.Items.Count = 0 Then
            MsgBox("Anda Belum Memilih Data", vbInformation, "Informasi")
        Else
            Dim Data As Object
            For Each Data In ListBox1.SelectedItems
                ListBox2.Items.Add(Data)
            Next
        End If
     End Sub
 5. Button "Copy Semua"
 >> Kodingnya Adalah
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        If ListBox1.Items.Count = 0 Then
            MsgBox("Data Belum Tersedia", vbInformation, "Informasi")
        Else
            ListBox2.Items.AddRange(ListBox1.Items)
        End If
    End Sub
  5. Button "Hapus Satu"
 >> Kodingnya Adalah
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Dim Data As Object
        Data = ListBox2.SelectedItem
        ListBox2.Items.Remove(Data)
    End Sub
 6. Button "Hapus Beberapa"
 >> Kodingnya Adalah
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        For i As Integer = 0 To ListBox2.SelectedIndices.Count - 1
            ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
        Next
     End Sub
  7. Button "Hapus Semua"
 
 >> Kodingnya Adalah
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        ListBox2.Items.Clear()
    End Sub
  8. Button "Rest"
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        ListBox1.Items.Clear()
        ListBox2.Items.Clear()
     End Sub
 9. Button "Tutup"
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        Me.Close()
    End Sub
 End Class

 ===============================================================================
Tampilan Peringatan Pada Beberapa Tombol
 ===============================================================================

Button "Masukan"
Button "Copy Satu" 
Button "Copy Beberapa" 
Button "Copy Semua"