Sabtu, 10 November 2012

Tugas 4 vb

1.RadioButton
saat pertama di run











saat dipilih












codingnya



Public Class Form1

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

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.Enabled = False
    End Sub

    Private Sub RdKawin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RdKawin.CheckedChanged
        If RdPria.Checked = True Then
            If RdKawin.Checked = True Then
                TextBox1.Text = "Anda Sudah Memiliki Seorang Istri"
            End If
        ElseIf RdWanita.Checked = True Then
            If RdWanita.Checked = True Then
                TextBox1.Text = "Anda Sudah Memiliki Seorang Suami"
            End If
        End If
    End Sub



    Private Sub RdTidakKawin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RdTidakKawin.CheckedChanged
        If RdPria.Checked = True Then
            If RdTidakKawin.Checked = True Then
                TextBox1.Text = "Anda Harus Mencari Seorang Istri"
            End If
        ElseIf RdWanita.Checked = True Then
            If RdWanita.Checked = True Then
                TextBox1.Text = "Anda Harus Mencari Seorang Suami"
            End If
        End If
    End Sub


    Private Sub RdPria_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RdPria.CheckedChanged
        If RdKawin.Checked = True Then
            If RdPria.Checked = True Then
                TextBox1.Text = "Anda Sudah Memiliki Seorang Istri"
            End If
        ElseIf RdTidakKawin.Checked = True Then
            If RdPria.Checked = True Then
                TextBox1.Text = "Anda Harus Mencari Seorang Istri"
            End If
        End If

    End Sub

    Private Sub RdWanita_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RdWanita.CheckedChanged
        If RdKawin.Checked = True Then
            If RdWanita.Checked = True Then
                TextBox1.Text = "Anda Sudah Memiliki Seorang Suami"
            End If
        ElseIf RdTidakKawin.Checked = True Then
            If RdWanita.Checked = True Then
                TextBox1.Text = "Anda Harus Mencari Seorang Suami"
            End If
        End If

    End Sub
End Class

2.Listbox
saat pertama di run








saat uda di isi










codingnya


Public Class Form1

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

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

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

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.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 Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.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 Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        ListBox2.SelectionMode = SelectionMode.One

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

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.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 Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        ListBox2.Items.Clear()
    End Sub

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

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub
End Class



Tidak ada komentar:

Posting Komentar