Skip to content

Jawaban Soal 2 (Rahima)

Januari 29, 2012

Kasus: http://mesran.wordpress.com/2012/01/26/soal-quiz-online-hari-selasa-2/

Public Class Form1

Sub bersih()
N_Pmblian.Text = “”
Kd_Barang.Text = “”
Nm_Barang.Text = “”
MEREK.Text = “”
Harga.Text = “”
Jlh_Beli.Text = “”
Ttl_Harga.Text = “”
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Kd_Barang.Items.Add(“TS001”)
Kd_Barang.Items.Add(“TS002”)
Kd_Barang.Items.Add(“VG001”)
Kd_Barang.Items.Add(“VG002”)
buat_tabel()
End Sub
Sub isi_tabel()
Dim lst As New ListViewItem
lst.Text = N_Pmblian.Text
lst.SubItems.Add(Kd_Barang.Text)
lst.SubItems.Add(Nm_Barang.Text)
lst.SubItems.Add(MEREK.Text)
lst.SubItems.Add(Harga.Text)
lst.SubItems.Add(Jlh_Beli.Text)
lst.SubItems.Add(Ttl_Harga.Text)
LV.Items.Add(lst)
End Sub
Private Sub Kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kd_Barang.SelectedIndexChanged
Call Cek()
End Sub

Private Sub BtnBersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Brsh.Click
bersih()
End Sub
Private Sub BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Keluar.Click
End
End Sub
Sub buat_tabel()
LV.Columns.Add(“No.Pembelian”, 100, HorizontalAlignment.Center)
LV.Columns.Add(“Kode Barang”, 100, HorizontalAlignment.Center)
LV.Columns.Add(“Nama Barang”, 100, HorizontalAlignment.Center)
LV.Columns.Add(“Merek”, 100, HorizontalAlignment.Center)
LV.Columns.Add(“Harga”, 100, HorizontalAlignment.Center)
LV.Columns.Add(“Jumlah Beli”, 100, HorizontalAlignment.Center)
LV.Columns.Add(“Total Harga”, 100, HorizontalAlignment.Center)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Private Sub Jmlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Jlh_Beli.KeyPress
If e.KeyChar = vbCr Then
Ttl_Harga.Text = Jlh_Beli.Text * Harga.Text
End If
End Sub

Private Sub BtnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Smpn.Click
isi_tabel()
bersih()
End Sub
Sub Cek()
Dim x As String
x = Microsoft.VisualBasic.Left(Kd_Barang.Text, 2)
If x = “TS” Then
MEREK.Text = “Toshiba”
x = Microsoft.VisualBasic.Right(Kd_Barang.Text, 3)
If x = “001” Then
Harga.Text = “105000”
Nm_Barang.Text = “Flasdisk 4GB”
ElseIf x = “002” Then
Harga.Text = “90000”
Nm_Barang.Text = “Flasdisk 2GB”
End If
ElseIf x = “VG” Then
MEREK.Text = “V-Gen”
x = Microsoft.VisualBasic.Right(Kd_Barang.Text, 3)
If x = “001” Then
Harga.Text = “75000”
Nm_Barang.Text = “Flasdisk 4GB”
ElseIf x = “002” Then
Harga.Text = “60000”
Nm_Barang.Text = “Flasdisk 2GB”
End If
End If
End Sub

Private Sub BtnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Hps_Semua.Click
LV.Items.Clear()
End Sub

Private Sub BtnHpsDplih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Hps_Dplih.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
End Class

Hasilnya :

From → Uncategorized

Tinggalkan sebuah Komentar

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: