Senin, 10 April 2017

Contoh penggunaan combo box & list box pada Visual Studio 2015


KODINGNYA:

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Label1.Text = "pilih data yang akan dipilih"
        With Me.ComboBox1
            .Items.Add("Neng")
            .Items.Add("Ibnu")
            .Items.Add("Risang")
            .Items.Add("Dhimas")
            .Items.Add("Bangkit")
            .Items.Add("Tedja")
        End With
        Button1.Text = "Masukan Datanya"
        ListBox2.Items.Add("Nama yang akan dimasukkan")
        ListBox2.Items.Add("----------")
        Label2.Text = "Form untuk memasukan data"
        Button2.Text = "Hapus Data"
        Button3.Text = "Hapus Semua"

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MsgBox("Anda akan memasukan datanya")
        With ListBox2
            .Items.Add(ComboBox1.Text)
        End With
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        MsgBox("Anda akan menghapus datanya")
        ListBox2.Items.Remove(ListBox2.SelectedItem)
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        MsgBox("Anda akan menghapus data semuanya")
        ListBox2.Items.Clear()
        ListBox2.Items.Add("Nama yang akan dimasukkan")
        ListBox2.Items.Add("----------")
    End Sub

End Class



0 komentar:

Posting Komentar