Posted by : Yusuf Suprianto Minggu, 11 November 2012


1.    Membuat Program dengan checkbox

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = ""
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        Dim control As Windows.Forms.CheckBox
        TextBox1.Text = ""
        For Each control In Me.GroupBox1.Controls
            If control.Checked = True Then
                TextBox1.Text &= control.Text & ","

            End If

        Next
        TextBox1.Text = Microsoft.VisualBasic.Left(TextBox1.Text, Len(TextBox1.Text) - 1)
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        Dim control As Windows.Forms.CheckBox
        TextBox1.Text = ""
        For Each control In Me.GroupBox1.Controls
            If control.Checked = True Then
                TextBox1.Text &= control.Text & ","

            End If

        Next
        TextBox1.Text = Microsoft.VisualBasic.Left(TextBox1.Text, Len(TextBox1.Text) - 1)
    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        Dim control As Windows.Forms.CheckBox
        TextBox1.Text = ""
        For Each control In Me.GroupBox1.Controls
            If control.Checked = True Then
                TextBox1.Text &= control.Text & ","

            End If

        Next
        TextBox1.Text = Microsoft.VisualBasic.Left(TextBox1.Text, Len(TextBox1.Text) - 1)
    End Sub

    Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
        Dim control As Windows.Forms.CheckBox
        TextBox1.Text = ""
        For Each control In Me.GroupBox1.Controls
            If control.Checked = True Then
                TextBox1.Text &= control.Text & ","

            End If

        Next
        TextBox1.Text = Microsoft.VisualBasic.Left(TextBox1.Text, Len(TextBox1.Text) - 1)
    End Sub

    Private Sub CheckBox5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox5.CheckedChanged
        Dim control As Windows.Forms.CheckBox
        TextBox1.Text = ""
        For Each control In Me.GroupBox1.Controls
            If control.Checked = True Then
                TextBox1.Text &= control.Text & ","

            End If

        Next
        TextBox1.Text = Microsoft.VisualBasic.Left(TextBox1.Text, Len(TextBox1.Text) - 1)
    End Sub

    Private Sub CheckBox6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox6.CheckedChanged
        Dim control As Windows.Forms.CheckBox
        TextBox1.Text = ""
        For Each control In Me.GroupBox1.Controls
            If control.Checked = True Then
                TextBox1.Text &= control.Text & ","

            End If

        Next
        TextBox1.Text = Microsoft.VisualBasic.Left(TextBox1.Text, Len(TextBox1.Text) - 1)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Close()
    End Sub
End Class

2.    Membuat Program dengan radiobutton

Public Class Form1


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

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        TextBox1.Text = ""
        If RadioButton1.Checked = True Then
        Else
            TextBox1.Text &= "Suami"
        End If
        If RadioButton2.Checked = True Then
        Else
            TextBox1.Text &= "Istri"
        End If

    End Sub

    Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
        TextBox1.Text = ""
        If RadioButton1.Checked = True Then
        Else
            TextBox1.Text &= ""
        End If
        If RadioButton2.Checked = True Then
        Else
            TextBox1.Text &= ""
        End If

    End Sub
End Class

3.    Membuat Program dengan listbox

Public Class Form1

    Private Sub btisi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btisi.Click
        Dim control As Windows.Forms.ListBox
        TextBox1.Text = TextBox1.Text
        TextBox1.Text = ListBox1.Items.Add(TextBox1.Text)
    End Sub

    Private Sub bt10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt10.Click
        For bil = 1 To 10
            ListBox1.Items.Add(bil)
        Next
    End Sub

    Private Sub btpindah1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btpindah1.Click
        ListBox1.Text = ListBox2.Items.Add(ListBox1.Text)
    End Sub

    Private Sub btpindah2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btpindah2.Click
        ListBox1.SelectionMode = SelectionMode.MultiExtended
        Dim i, j As Integer
        j = ListBox1.Items.Count
        For i = 0 To j - 1
            Try
                ListBox2.Items.Add(ListBox1.Items(ListBox1.SelectedIndices(i)))
            Catch ex As Exception
                j -= 1
            End Try
        Next
    End Sub

    Private Sub btpindah3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btpindah3.Click
        ListBox1.SelectionMode = SelectionMode.MultiExtended

        Dim Jumlah As Integer = ListBox1.Items.Count
        For i = 0 To Jumlah - 1
            ListBox2.Items.Add(ListBox1.Items(i))
        Next
    End Sub

    Private Sub bthps1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bthps1.Click
        ListBox2.SelectionMode = SelectionMode.One

        ListBox2.Items.Remove(ListBox2.SelectedItem)
    End Sub

    Private Sub bthps2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bthps2.Click
        ListBox2.SelectionMode = SelectionMode.MultiExtended
        Dim i, j As Integer
        j = ListBox2.Items.Count
        For i = 0 To j - 1
            Try
                ListBox2.Items.RemoveAt(ListBox2.SelectedIndex)
            Catch ex As Exception
                j -= 1
            End Try
        Next
    End Sub

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

    Private Sub btclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btclose.Click
        Me.Close()
    End Sub
End Class



Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © QIEBAE -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -