Soal Kuis Pak Mesran Selasa

Postingan Jawaban No 2  ( irsyahdi dalimunthe )

Untuk kasus lihat disini

http://mesran.wordpress.com/2012/01/26/soal-quiz-online-hari-selasa-2/comment-page-3/#comment-4325

Listing Program Hasil Kuis Pak Mesraan 

Public Class latihan
Sub table()
ListView1.Columns.Add(“NO.Pembelian”, 80, HorizontalAlignment.Left)
ListView1.Columns.Add(“Kode Brg”, 80, HorizontalAlignment.Left)
ListView1.Columns.Add(“Nama Brg”, 80, HorizontalAlignment.Left)
ListView1.Columns.Add(“Merk”, 80, HorizontalAlignment.Left)
ListView1.Columns.Add(“Harga”, 80, HorizontalAlignment.Left)
ListView1.Columns.Add(“Jumlah Beli”, 80, HorizontalAlignment.Left)
ListView1.Columns.Add(“T.Gaji”, 80, HorizontalAlignment.Left)
ListView1.View = View.Details
ListView1.GridLines = True
ListView1.FullRowSelect = True
End Sub
Sub isi()
Dim lst As New ListViewItem
lst.Text = no.Text
lst.SubItems.Add(kode.Text)
lst.SubItems.Add(nama.Text)
lst.SubItems.Add(merk.Text)
lst.SubItems.Add(harga.Text)
lst.SubItems.Add(jumlah.Text)
lst.SubItems.Add(total.Text)
ListView1.Items.Add(lst)
End Sub

Private Sub latihan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
table()

kode.Items.Add(“TS-001”)
kode.Items.Add(“TS-002”)
kode.Items.Add(“VG-001”)
kode.Items.Add(“VG-002”)

End Sub
Private Sub hitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hitung.Click
total.Text = Val(jumlah.Text) * Val(harga.Text)

End Sub

Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
Dim latihan As String
Microsoft.VisualBasic.Left(kode.Text, 2)
latihan = Microsoft.VisualBasic.Left(kode.Text, 2)
If latihan = “TS” Then
merk.Text = “TOSHIBA”
ElseIf latihan = “VG” Then
merk.Text = “V-Gen”
End If
latihan = Microsoft.VisualBasic.Right(kode.Text, 3)
If latihan = “001” Then
nama.Text = “Flasdic 4GB”
ElseIf latihan = “002” Then
nama.Text = “Flasdisc 2GB”
ElseIf latihan = “003” Then
nama.Text = “TV”

End If
no.Text = Microsoft.VisualBasic.Right(kode.Text, 3)

End Sub

Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
Dim i As Byte
i = MsgBox(“Apakah Anda Ingin Keluar Dari program Ini”, MsgBoxStyle.YesNo, “Kembali Ke Menu Utama”)
If i = vbYes Then
End

End If
End Sub

Private Sub jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlah.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
If tombol = 13 Then
hitung_Click(sender, e)

End If
End Sub

Private Sub jumlah_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlah.TextChanged

End Sub

Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
isi()
no.Text = “”
kode.Text = “”
nama.Text = “”
merk.Text = “”
harga.Text = “”
jumlah.Text = “”
total.Text = “”

End Sub

Private Sub hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus.Click
ListView1.Items.Remove(ListView1.SelectedItems(0))
End Sub

Private Sub hapusss_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapusss.Click
ListView1.Items.Clear()
End Sub

End Class

Hasil Program 

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: