CHECKBOX
- Buat 6 checkbox (Indonesia, inggris, Arab, Sunda, Jawa, Lain-lain)
- Pilih groupbox (Kemampuan Berbahasa), kemudian masukkan semua checkbox pada groupbox
- masukkan textbox dan button (Pilih) pada form
Listing Programnya :
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.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 CheckBox7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox7.CheckedChanged
Dim control As Windows.Forms.CheckBox
TextBox1.Text = ""
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
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 CheckBox7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox7.CheckedChanged
Dim control As Windows.Forms.CheckBox
TextBox1.Text = ""
End Sub
End Class
Setelah selesai mengisi listing program kemudian Run program tersebut dan pilih bahasa yang anda
pilih lalu tekan button (Pilih)
Dan akan menghasilkan :
RADIOBUTTON
Buat form seperti di bawah ini :
Lalu masukkan listing programnya :
Public Class Form1
Private Sub RbKawin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RbKawin.CheckedChanged
TextBox1.Text = ""
If RbPria.Checked = True Then
Else
TextBox1.Text &= "Suami"
End If
If RbWanita.Checked = True Then
Else
TextBox1.Text &= "Istri"
End If
End Sub
Private Sub RbTdkwin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RbTdkwin.CheckedChanged
TextBox1.Text = ""
If RbPria.Checked = True Then
Else
TextBox1.Text &= ""
End If
If RbWanita.Checked = True Then
Else
TextBox1.Text &= ""
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
End Class
Private Sub RbKawin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RbKawin.CheckedChanged
TextBox1.Text = ""
If RbPria.Checked = True Then
Else
TextBox1.Text &= "Suami"
End If
If RbWanita.Checked = True Then
Else
TextBox1.Text &= "Istri"
End If
End Sub
Private Sub RbTdkwin_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RbTdkwin.CheckedChanged
TextBox1.Text = ""
If RbPria.Checked = True Then
Else
TextBox1.Text &= ""
End If
If RbWanita.Checked = True Then
Else
TextBox1.Text &= ""
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
End Class
Setelah selesai mengisi listing program kemudian Run program tersebut dan pilih jenis kelamin dan status, maka akan ada beberapa kemungkinan
:
"Istri" pada textbox
==> Jika yang dipilih jenis kelamin “Wanita” dan status “Kawin”
maka akan muncul
" "Suami" pada textbox
1. ==>
Jika yang dipilih jenis kelamin “Pria/Wanita” dan
status “Tidak Kawin” maka
textbox akan kosong
Listing
program :
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)
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 Bt_Satu.Click
ListBox1.Text = ListBox2.Items.Add(ListBox1.Text)
End Sub
Private Sub Bt_Beberapa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Beberapa.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 Bt_Semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Semua.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 Bt_Hapus_Satu.Click
ListBox2.SelectionMode = SelectionMode.One
ListBox2.Items.Remove(ListBox2.SelectedItem)
End Sub
Private Sub Bt_Hapus_Beberapa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Hapus_Beberapa.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 Bt_Hapus_Semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Hapus_Semua.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
End Class
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)
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 Bt_Satu.Click
ListBox1.Text = ListBox2.Items.Add(ListBox1.Text)
End Sub
Private Sub Bt_Beberapa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Beberapa.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 Bt_Semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Semua.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 Bt_Hapus_Satu.Click
ListBox2.SelectionMode = SelectionMode.One
ListBox2.Items.Remove(ListBox2.SelectedItem)
End Sub
Private Sub Bt_Hapus_Beberapa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Hapus_Beberapa.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 Bt_Hapus_Semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Hapus_Semua.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
End Class
Run program
Langkah - langkah :
- Ketik pada textbox lalu klik isi, kemudian tulisan di textbox akan pindah ke listbox 1
- Jika diklik tombol 1-10, maka akan terisi angka 1 sampai 10
- Kemudian pilih "Nadhif Hunaefi" dan klik tombol "Satu >" maka "Nadhif Hunaefi" masuk ke listbox2
- Pilih beberapa dari listbox1 kemudian klik “Beberapa >”, maka akan mengisi beberapa data yang dipilih
- Jika klik “Semua >” maka data yang ada di listbox1 akan masuk semua ke listbox2
- Jika klik “Hapus satu” maka akan hilang satu yang dipilih pada listbox2 seperti “Nadhif Hunaefi” dan akan terhapus
- Jika diblok beberapa dan klik “Hapus beberapa >” maka akan terhapus
- Untuk yang terakhir klik “Hapus Semua” maka listbox2 semua akan terhapus
0 komentar:
Posting Komentar