Pada tugas visual basic yang ke-2 ini saya mencoba membuat program menghitung,tidak jauh beda dari tugas pertama cuma hanya menambahkan beberapa koding-koding baru,seperti messege box,clear dll.berikut adalah programnya
form 1
beriktut adalah koding form 1
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim x As String
x = MsgBox("Yakin Keluar", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Konfirmasi")
If x = vbYes Then
End If
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = "0"
TextBox2.Text = "0"
TextBox3.Text = "0"
TextBox4.Text = "0"
TextBox5.Text = "0"
TextBox6.Text = "0"
TextBox7.Text = "0"
TextBox8.Text = "0"
TextBox9.Text = "0"
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Form2.Show()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
If ComboBox3.Text = "Jus" Then
TextBox1.Text = "5000"
Else
End If
If ComboBox3.Text = "Kopi" Then
TextBox1.Text = "2000"
Else
End If
If ComboBox3.Text = "Teh manis" Then
TextBox1.Text = "2000"
Else
End If
If ComboBox3.Text = "Minuman botol" Then
TextBox1.Text = "2500"
Else
End If
If ComboBox3.Text = "Minuman kaleng" Then
TextBox1.Text = "4500"
Else
End If
If ComboBox3.Text = "Air putih" Then
TextBox1.Text = "0"
End If
End Sub
Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectedIndexChanged
If ComboBox4.Text = "Pisang" Then
TextBox5.Text = "1000"
Else
End If
If ComboBox4.Text = "Apel" Then
TextBox5.Text = "4000"
Else
End If
If ComboBox4.Text = "Jeruk" Then
TextBox5.Text = "1500"
Else
End If
If ComboBox4.Text = "Gorengan" Then
TextBox5.Text = "500"
Else
End If
If ComboBox4.Text = "Puding" Then
TextBox5.Text = "2500"
End If
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
If ComboBox2.Text = "Ayam" Then
TextBox3.Text = "5000"
Else
End If
If ComboBox2.Text = "Daging" Then
TextBox3.Text = "6000"
Else
End If
If ComboBox2.Text = "Telur" Then
TextBox3.Text = "2000"
Else
End If
If ComboBox2.Text = "Ikan" Then
TextBox3.Text = "4000"
Else
End If
If ComboBox2.Text = "Sea food" Then
TextBox3.Text = "5000"
Else
End If
If ComboBox2.Text = "Hati ampela" Then
TextBox3.Text = "4000"
Else
End If
If ComboBox2.Text = "Kikil" Then
TextBox3.Text = "5000"
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text = "1" Then
TextBox4.Text = "14000"
Else
End If
If ComboBox1.Text = "2" Then
TextBox4.Text = "19000"
Else
End If
If ComboBox1.Text = "3" Then
TextBox4.Text = "15000"
Else
End If
If ComboBox1.Text = "4" Then
TextBox4.Text = "18000"
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
TextBox7.Text = TextBox2.Text + +TextBox3.Text + +TextBox1.Text + +TextBox5.Text + +TextBox4.Text
TextBox9.Text = TextBox7.Text - TextBox8.Text
End Sub
Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged
TextBox2.Text = TextBox6.Text * 3000
End Sub
Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged
TextBox8.Text = TextBox7.Text * 0.1
End Sub
Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged
End Sub
End Class
pada form ini kita bisa memasukkan data makanan yang telah kita pilih,jika ingin memilih paket kita bisa melihatnya di form 2 dengan cara mengklik button "Lihat paket".di form ini juga tersedia button untuk mengisi ulang lagi data/membuat data yang baru, dan menutup data dengan memberikan konfirmasi terlebih dahulu.
form 2
pada form ini kita bisa melihat berbagai macam paket yang tersedia,jika ingin memilih salah satu paket kita mesti mengisi datanya di form 1.
Terima kasih Atas perhatiannya.Jika ada salh mohon di maafkan.