Minggu, 11 November 2012

Program List Box dan Radio Button


 Program List Box
 Langkah-langkahnya :
1. Buka Aplikasi VB .Net 2010 dan buat project baru dengan desain di bawah ini !
2. Tulis Coding di bawah ini!
Private Sub btisi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btisi.Click
        Dim isi As String
        isi = txtisi.Text
        ListBox1.Items.Add(isi)
    End Sub



    Private Sub btangka_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btangka.Click
        Dim ulang As Integer
        Dim bil(9) As Integer
        bil(0) = 1
        For ulang = 1 To 9
            bil(ulang) = ulang + 1
        Next
        For ulang = 0 To 9
            ListBox1.Items.Add(bil(ulang))
        Next
    End Sub

    Private Sub btsatu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsatu.Click
        Dim satu As String
        satu = ListBox1.Text
        ListBox2.Items.Add(satu)
    End Sub

    Private Sub btbeberapa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btbeberapa.Click
        Dim A, B As Integer
        B = ListBox1.Items.Count
        For A = 0 To B - 1
            Try
                ListBox2.Items.Add(ListBox1.Items(ListBox1.SelectedIndices(A)))
            Catch ex As Exception
                B -= 1
            End Try
        Next
    End Sub

    Private Sub btsemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btsemua.Click
        Dim Jumlah As Integer = ListBox1.Items.Count
        For A = 0 To Jumlah - 1
            ListBox2.Items.Add(ListBox1.Items(A))
        Next
    End Sub

    Private Sub bthapussatu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bthapussatu.Click
        ListBox2.Items.Remove(ListBox2.SelectedItem)
    End Sub

    Private Sub bthapusbeberapa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bthapusbeberapa.Click
        Dim A, B As Integer
        B = ListBox2.Items.Count
        For A = 0 To B - 1
            Try
                ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
            Catch ex As Exception
                B -= 1
            End Try
        Next
    End Sub

    Private Sub bthapussemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bthapussemua.Click
        ListBox2.Items.Clear()
    End Sub

    Private Sub bttutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttutup.Click
        Me.Close()

    End Sub
3. Kemudian dalam listbox1 dan listbox2 pengaturan selection mode diubah menjadi multiextended
4. Jalankan program tersebut dan hasilnya di bawah ini !

Program Radio Button
Langkah-langkahnya :
1. Buka Aplikasi VB .Net 2010 dan buat project baru dengan desain di bawah ini!

2.  Tulis Coding di bawah ini!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim A, B, C, D As String
        A = Radiopria.Checked
        B = Radiowanita.Checked
        C = Radiokawin.Checked
        D = Radiotidakkawin.Checked

        If A = True And C = True Then
            txtpasangan.Text = "Istri"
        ElseIf B = True And C = True Then
            txtpasangan.Text = "Suami"
        ElseIf A = True And D = True Then
            txtpasangan.Text = "-"
        ElseIf B = True And D = True Then
            txtpasangan.Text = "-"
        End If
    End Sub

    Private Sub bttutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttutup.Click
        Me.Close()
    End Sub

3.  Jalankan program tersebut sehingga hasilnya di bawah ini !

Tidak ada komentar:

Posting Komentar