Aplikasi
pasangan hidup 
Untuk membuat aplikasi pasangan hidup
dengan Visual Basic 2010, pertama buat tampilan sebagai berikut :
Keterangan mengatur propertis pada
setiap control:
Label 1 : jenis kelamin (text)
Label 2 : status  (text)
Label 3 : pasangan hidup (text)
Panel 1 
Panel 2
RadioButton 1: Pria (text)
RadioButton 2: wanita (text)
RadioButton 3: menikah (text)
RadioButton 4: tidak menikah (text)
Button 1 
: pilih (text)
Button 2 
: tutup (text)
Public Class Form1
    Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
        If RadioButton1.Checked = True
And RadioButton3.Checked = True Then
           
TextBox1.Text = "ISTRI"
        ElseIf RadioButton2.Checked = True And RadioButton3.Checked = True Then
           
TextBox1.Text = "SUAMI"
        ElseIf RadioButton1.Checked = True Or RadioButton2.Checked = True And
RadioButton4.Checked = True Then
           
TextBox1.Text = "JOMBLO"
        End If
    End Sub
    Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
        Me.Close()
    End Sub
End Class
Setelah memasukan
kode, sekarang jalankan aplikasi, maka hasilnya sebgai berikut :
1.     
Jika
Pria – menikah 
2.     
Jika
wanita - menikah 
3.     
Jika
Pira - tidak menikah
4.     
Jika
Wanita - tidak menikah
ListBox
Untuk membuat aplikasi menggunakan ListBox
dengan Visual Basic 2010, pertama buat tampilan sebagai berikut :
Keterangan mengatur propertis pada
setiap control:
Textbox
listBox1
Listbox 2
Button 1 
: isi (text)
Button 2 
: 1-10 (text)
Button 3 
: satu > (text)
Button 4 
: Beberapa > (text)
Button 5 
: semua > (text)
Button 6 
: Hapus satu (text)
Button 7 
: Hapus beberapa (text)
Button 8 
: Hapus semua (text)
Setelah mengatur
propertis pada settiap control, masukan kode berikut pada setiap control :
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
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 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
Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button8.Click
       
ListBox2.Items.Clear()
    End Sub
End Class
Maka tampilan akhir
sebagai berikut :
Silahkan coba
aplikasi pada setiap button :D,,,,,







 
Tidak ada komentar:
Posting Komentar