KUIS ONLINE BELAJAR BAHASA PEMROGRAMAN
Postingan ini dibuat untuk memenuhi tugas kuis Online saya :
Silahkan dilihat .
Bentuk Form Awal
Inilah kode formnya :
Public Class Form1
Sub
BuatTabel()
Save.Columns.Add("Kode", 80, HorizontalAlignment.Center)
Save.Columns.Add("Nama", 80, HorizontalAlignment.Center)
Save.Columns.Add("Harga", 80, HorizontalAlignment.Center)
Save.Columns.Add("Merk", 80, HorizontalAlignment.Center)
Save.Columns.Add("Jumlah", 80,
HorizontalAlignment.Center)
Save.Columns.Add("Total", 80, HorizontalAlignment.Center)
Save.View = View.Details
Save.GridLines = True
Save.FullRowSelect = True
End Sub
Sub
IsiTabel()
Dim Lst
As New
ListViewItem
Lst.Text = Kode.Text
Lst.SubItems.Add(nama.Text)
Lst.SubItems.Add(Harga.Text)
Lst.SubItems.Add(Merk.Text)
Lst.SubItems.Add(Jumlah.Text)
Lst.SubItems.Add(Total.Text)
Save.Items.Add(Lst)
End Sub
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Kode.Items.Add("SE001")
Kode.Items.Add("SE002")
Kode.Items.Add("BB001")
Kode.Items.Add("BB002")
Call
BuatTabel()
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)
If x = "SE" Then
merk.Text = "Sony Ericson"
ElseIf
x = "BB" Then
merk.Text = "BlackBerry"
End If
x = Microsoft.VisualBasic.Right(Kode.Text,
3)
If x = "001" Then
nama.Text = "Handphone dengan Memory Up to 32GB"
ElseIf
x = "002" Then
nama.Text = "Handphone dengan Memory Up to 64GB"
End If
Select Case Kode.Text
Case "SE001"
harga.Text = "2500000"
Case
"SE002"
harga.Text = "3750000"
Case
"BB001"
harga.Text = "2800000"
Case
"BB002"
harga.Text = "5000000"
End Select
End Sub
Private Sub btnsimpan_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnsimpan.Click
IsiTabel()
Kode.Text = ""
nama.Text = ""
harga.Text = ""
merk.Text = ""
Jumlah.Text = ""
Total.Text = ""
End Sub
Private Sub Total_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
Total.KeyPress
Total.Text = harga.Text *
Val(Jumlah.Text)
End Sub
Private Sub btnhapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnhapus.Click
Save.Items.Clear()
End Sub
Private Sub Btnbatal_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnbatal.Click
Kode.Text = ""
nama.Text = ""
harga.Text = ""
merk.Text = ""
Jumlah.Text = ""
Total.Text = ""
End Sub
Private Sub btnkeluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnkeluar.Click
Me.Close()
End Sub
End Class
Dan dibawah ini hasilnya :
Hasil form
No comments:
Post a Comment
Silahkan tinggalkan komentar dibawah ini. Jadilah pembaca yang aktif. Gomawo ^^