Jawaban Quis On-Line Mata Kuliah Visual Pemogramman I pada Website Mesran.net
Untuk Mendesain tampilan di atas
Inputkan 7 buah Lebel
2 buah ComboBox
5 buah text Box
6 buah Buttob
1 bh ListVIew
2 Buah GroupBox
Tampilan Awalnya
Listing Programmanya :
Public Class Form1
Sub rancangTabel()
With LV
.Columns.Add("Kode", 50, HorizontalAlignment.Center)
.Columns.Add("Nama Berang", 80, HorizontalAlignment.Left)
.Columns.Add("Harga", 80, HorizontalAlignment.Center)
.Columns.Add("Jumlah", 55, HorizontalAlignment.Center)
.Columns.Add("Total Harga", 70, HorizontalAlignment.Center)
.Columns.Add("Diskon", 70, HorizontalAlignment.Center)
.Columns.Add("Total Bayar", 70, HorizontalAlignment.Center)
.GridLines = True
.FullRowSelect = True
.View = View.Details
End With
End Sub
Sub MasukTabel()
Dim frendiks As New ListViewItem
frendiks.Text = kode.Text
frendiks.SubItems.Add(nama.Text)
frendiks.SubItems.Add(harga.Text)
frendiks.SubItems.Add(jumlah.Text)
frendiks.SubItems.Add(total.Text)
frendiks.SubItems.Add(diskon.Text)
frendiks.SubItems.Add(total_bayar.Text)
LV.Items.Add(frendiks)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
rancangTabel()
kode.Items.Add("TS001")
kode.Items.Add("TS002")
kode.Items.Add("TS003")
kode.Items.Add("TS004")
Dim x As Integer
For x = 1 To 10
jumlah.Items.Add(x)
Next
End Sub
Sub hapus()
kode.Text = ""
nama.Text = ""
harga.Text = ""
jumlah.Text = ""
total.Text = ""
diskon.Text = ""
total_bayar.Text = ""
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.Right(kode.Text, 3)
Select Case x
Case "001" : nama.Text = "Soni 15inchi"
Case "002" : nama.Text = "Soni 22 inchi"
Case "003" : nama.Text = "Soni 24 inchi"
Case "004" : nama.Text = "Soni 32 inchi"
End Select
If kode.Text = "TS001" Then
harga.Text = 1500000
ElseIf kode.Text = "TS002" Then
harga.Text = 1200000
ElseIf kode.Text = "TS003" Then
harga.Text = 1000000
ElseIf kode.Text = "TS004" Then
harga.Text = 1100000
Else
harga.Text = 0
End If
End Sub
Private Sub jumlah_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlah.SelectedIndexChanged
total.Text = Val(harga.Text) * Val(jumlah.Text)
If total.Text >= 2500000 Then
diskon.Text = Val(total.Text) * 0.1
Else
diskon.Text = 0
End If
End Sub
Private Sub baru_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles baru.Click
total_bayar.Text = Val(total.Text) - Val(diskon.Text)
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
MasukTabel()
hapus()
kode.Focus()
End Sub
Private Sub batal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles batal.Click
hapus()
End Sub
Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
End
End Sub
Private Sub hapussemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapussemua.Click
LV.Items.Clear()
End Sub
Private Sub hapus1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus1.Click
If LV.SelectedItems.Count <> 0 Then
LV.Items.Remove(LV.SelectedItems(0))
Else
MsgBox("Pilih Yang Mau di Hapus.!")
End If
End Sub
End Class
tampilan Setelah di Jalankan.
0 komentar:
Posting Komentar