Saturday, October 12, 2013

Yuk! Belajar Pemrograman Visual Basic dot Net

Selesaikanlah Kasus Berikut:
Buatlah program untuk menampilkan hasil ke listview untuk kasus Latihan Listview Perhitungan Penjualan Barang
Berikut Jawaban Program:
Design Form
yang 22
Listing Program:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
kode.Items.Add("TS001")
kode.Items.Add("TS002")
kode.Items.Add("VG001")
kode.Items.Add("VG002")
BuatTabel()
End Sub
Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Left(kode.Text, 2)
Select Case x
Case "TS" : merk.Text = "Toshiba"
Case "VG" : merk.Text = "V-Gen"
End Select
Dim y As String
y = Microsoft.VisualBasic.Right(kode.Text, 3)
Select Case y
Case "001" : nama.Text = "Flashdisk 4GB"
Case "002" : nama.Text = "Flashdisk 2GB"
End Select
If x = "TS" And y = "001" Then
harga.Text = "105000"
ElseIf x = "TS" And y = "002" Then
harga.Text = "75000"
ElseIf x = "VG" And y = "001" Then
harga.Text = "90000"
ElseIf x = "VG" And y = "002" Then
harga.Text = "60000"
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
total.Text = Val(harga.Text) * Val(jumlah.Text)
End If
End Sub
Sub BuatTabel()
LV.Columns.Add("No Pembelian", 80, HorizontalAlignment.Center)
LV.Columns.Add("Kode Barang", 180, HorizontalAlignment.Left)
LV.Columns.Add("Nama Barang", 80, HorizontalAlignment.Center)
LV.Columns.Add("Merk", 80, HorizontalAlignment.Center)
LV.Columns.Add("Harga", 80, HorizontalAlignment.Center)
LV.Columns.Add("Jumlah Beli", 80, HorizontalAlignment.Center)
LV.Columns.Add("Total Harga", 80, HorizontalAlignment.Center)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub IsiTabel()
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)
LV.Items.Add(Lst)
End Sub
Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
IsiTabel()
End Sub
Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
LV.Items.Clear()
End Sub
Private Sub btnhapusyang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapusyang.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
End
End Sub
Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
no.Text = ""
nama.Text = ""
kode.Text = ""
merk.Text = ""
harga.Text = ""
total.Text = ""
jumlah.Text = ""
End Sub
End Class
yang 11
yang 33
Demikianlah Postingan Dari Saya, saya ucapkan terima kasih..

No comments:

Post a Comment