0% found this document useful (0 votes)
29 views

Syntax Listview

This document contains code for a form in Visual Basic that allows a user to add items to a shopping cart. It initializes variables, loads dropdown menus, and handles events like selecting an item type or entering a quantity. When an item is added, it calculates the price, total, discount, and grand total, and adds the item details to a list view. It also includes a method to clear fields after an item is added.

Uploaded by

Ahmad Syauqie
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Syntax Listview

This document contains code for a form in Visual Basic that allows a user to add items to a shopping cart. It initializes variables, loads dropdown menus, and handles events like selecting an item type or entering a quantity. When an item is added, it calculates the price, total, discount, and grand total, and adds the item details to a list view. It also includes a method to clear fields after an item is added.

Uploaded by

Ahmad Syauqie
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Public Class Form1 Dim list As ListViewItem Dim vharga As Double Dim vjumlah As Double Dim vtotal As Double

Dim vdiskon As Double Dim vgrand As Double Dim i As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load With cbo_jenis.Items .Clear() .Add("Komputer") .Add("Akuntansi") .Add("Umum") .Add("Agama") End With Dim u As Double For u = 0 To 1000 With Me.ComboBox1.Items .Add(u) End With Next tanggal.Text = Format(Now, "ddd, dd MMM yyyy") End Sub Private Sub kdbuku_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_jenis.SelectedIndexChanged Select Case cbo_jenis.Text Case Is = "Komputer" kdbuku.Text = "KPT" judul.Text = "Visual Basic" vharga = 120000 Case Is = "Akuntansi" kdbuku.Text = "AKT" judul.Text = "Accounting Principles" vharga = 250000 Case Is = "Umum" kdbuku.Text = "UMU" judul.Text = "La Tahzan" vharga = 200000 Case Else kdbuku.Text = "AGA" judul.Text = "Kumpulan Hadist Sahih" vharga = 500000 End Select at.Text = "Rp " & Format(vharga, "#,##0") End Sub Private Sub qty_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles qty.KeyDown If e.KeyCode <> Keys.Enter Then Exit Sub vjumlah = Val(qty.Text) * vharga vtotal = vtotal + vjumlah If RadioButton1.Checked = True Then vdiskon = 10 / 100 * vtotal ElseIf RadioButton2.Checked = True Then vdiskon = 0 End If

vgrand = vtotal - vdiskon diskon.Text = "Rp " & Format(vdiskon, "#,##0") jumlah.Text = "Rp " & Format(vjumlah, "#,##0") total.Text = "Rp " & Format(vtotal, "#,##0") grand.Text = "Rp " & Format(vgrand, "#,##0") list = ListView1.Items.Add(cbo_jenis.Text) list.SubItems.Add(judul.Text) list.SubItems.Add(kdbuku.Text) list.SubItems.Add(at.Text) list.SubItems.Add(qty.Text) list.SubItems.Add(jumlah.Text) i = i + 1 If i Mod 2 < 1 Then list.BackColor = Color.Aqua Call kosong() End Sub Sub kosong() With Me .judul.Clear() .kdbuku.Clear() .at.Clear() .qty.Clear() .jumlah.Clear() End With End Sub End Class

You might also like