SOAL 1:
Buatlah program untuk menampilkan hasil ke listview untuk Kasus
Pemrograman
Pemakaian Listrik
SOAL 2:
Buatlah program vb net untuk menampilkan output seperti
dibawah ini.
GAJI PEGAWAI PT. TELKOM
--------------------------------------------
Nama
Pegawai : ?
Gol : ?
Gaji :
Pajak
:
Pinjaman : ?
Gaji Bersih :
--------------------------------------------
Proses
Gol=IIIA maka Gaji = 1500000
Gol=IIIB maka Gaji = 2500000
Gol=IIIC maka Gaji = 3500000
Pajak = 15% dari Gaji
Gaji Bersih = Gaji - Pinjaman - Gaji Bersih
PENYELESAIAN:
SOAL 1
-->
Public Class
Form1
Sub
buattable()
lv.Columns.Add("No
Pelanggan", 60, HorizontalAlignment.Center)
lv.Columns.Add("nama
daerah", 80, HorizontalAlignment.Center)
lv.Columns.Add("tipe",
70, HorizontalAlignment.Center)
lv.Columns.Add("Biaya",
65, HorizontalAlignment.Center)
lv.Columns.Add("Harga
PerKWH", 65, HorizontalAlignment.Center)
lv.Columns.Add("Meter
Sekarang", 80, HorizontalAlignment.Center)
lv.Columns.Add("Meter
Lalu", 70, HorizontalAlignment.Center)
lv.Columns.Add("Pemakaian",
65, HorizontalAlignment.Center)
lv.Columns.Add("Total
Tagihan", 65, HorizontalAlignment.Center)
lv.Columns.Add("Pajak",
65, HorizontalAlignment.Center)
lv.Columns.Add("Pembayaran",
65, HorizontalAlignment.Center)
Lv.GridLines = True
Lv.FullRowSelect
= True
Lv.View =
View.Details
End Sub
Sub
isitable()
Dim x As New ListViewItem
With x
.Text =
nmr.Text
.SubItems.Add(daerah.Text)
.SubItems.Add(tipe.Text)
.SubItems.Add(Bbeban.Text)
.SubItems.Add(kwh.Text)
.SubItems.Add(MMini.Text)
.SubItems.Add(MMlalu.Text)
.SubItems.Add(pemakai.Text)
.SubItems.Add(total.Text)
.SubItems.Add(pajak.Text)
.SubItems.Add(bayar.Text)
lv.Items.Add(x)
End With
End Sub
Sub
add_daerah()
With
daerah
.Items.Add("MEDAN")
.Items.Add("BELAWAN")
.Items.Add("AKSARA")
.Items.Add("MARENDAL")
.Items.Add("BINJAI")
.Items.Add("LUBUK
PAKAM")
End With
End Sub
Sub
add_tipe()
With tipe
.Items.Add("TOKO")
.Items.Add("RUMAH")
.Items.Add("SWALAYAN")
.Items.Add("PABRIK")
End With
End Sub
Private Sub
tipe_SelectedIndexChanged(ByVal sender
As System.Object, ByVal
e As
System.EventArgs) Handles
tipe.SelectedIndexChanged
If
tipe.Text = "TOKO" Then
Bbeban.Text
= 150000
kwh.Text =
500
ElseIf
tipe.Text = "RUMAH" Then
kwh.Text =
200
Bbeban.Text
= 50000
ElseIf
tipe.Text = "SWALAYAN" Then
kwh.Text =
1500
Bbeban.Text
= 400000
ElseIf
tipe.Text = "PABRIK" Then
kwh.Text =
1000
Bbeban.Text
= 1000000
End If
MMini.Text = ""
MMlalu.Text = ""
pemakai.Text = ""
total.Text = ""
pajak.Text = ""
bayar.Text = ""
nmr.Text = ""
End Sub
Sub
bersih()
nmr.Text = ""
daerah.Text = ""
tipe.Text = ""
Bbeban.Text = ""
kwh.Text = ""
MMini.Text = ""
MMlalu.Text = ""
pemakai.Text = ""
total.Text = ""
pajak.Text = ""
bayar.Text = ""
End Sub
Sub
add_nmr()
Dim x,
y, z As String
x =
Microsoft.VisualBasic.Left(daerah.Text, 3)
y =
Microsoft.VisualBasic.Left(tipe.Text, 3)
z = "00"
& (tipe.SelectedIndex + 1)
nmr.Text = x
& "-" & y & "-" & z
End Sub
Private Sub
MMlalu_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
MMlalu.KeyPress
If
e.KeyChar = Chr(13) Then
If
MMlalu.Text = "" Or
MMini.Text = ""
Then
MsgBox("Isi
Dengan Benar")
Else
If
IsNumeric(MMlalu.Text) = True And IsNumeric(MMini.Text) = True
Then
pemakai.Text
= MMini.Text -
MMlalu.Text
total.Text
= Bbeban.Text +
(pemakai.Text * kwh.Text)
pajak.Text
= (15 / 100) *
total.Text
bayar.Text
=
Val(total.Text) + Val(pajak.Text)
Call
add_nmr()
Else
MsgBox("isi
dengan angka !!!")
pemakai.Text
= ""
total.Text
= ""
pajak.Text
= ""
bayar.Text
= ""
nmr.Text
= ""
End
If
End
If
End If
End Sub
Private Sub
Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call
add_daerah()
Call
add_tipe()
Call
buattable()
End Sub
Private Sub
daerah_SelectedIndexChanged(ByVal
sender As
System.Object, ByVal e As
System.EventArgs) Handles
daerah.SelectedIndexChanged
Dim i As String
i = daerah.Text
bersih()
daerah.Text = i
End Sub
Private Sub
Button2_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
Button2.Click
bersih()
End Sub
Private Sub
Button1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
Button1.Click
isitable()
End Sub
Private Sub
Button3_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
Button3.Click
lv.Items.Clear()
End Sub
Private Sub
Button4_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
Button4.Click
lv.Items.Remove(lv.SelectedItems(0))
End Sub
End Class
soal 2:
-->
Public
Class Form1
Sub
bersih()
'gol.Text =
""
'gol.Text =
""
'gaji.Text =
""
'pajk.Text =
""
pinjm.Text
= ""
gjbrsh.Text
= ""
End
Sub
Private
Sub
Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
gol.Items.Add("IIIA")
gol.Items.Add("IIIB")
gol.Items.Add("IIIC")
End Sub
Private Sub
gaji_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
gaji.TextChanged
pajk.Text
= gaji.Text - 15%
End Sub
Private Sub
Btnproses_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
Btnproses.Click
gjbrsh.Text
= "Rp.
" & Format(pajk.Text - pinjm.Text, "###,###,###")
End Sub
Private Sub
gol_SelectedIndexChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
gol.SelectedIndexChanged
bersih()
If
gol.Text = "IIIA" Then
gaji.Text
= "1500000"
ElseIf
gol.Text = "IIIB" Then
gaji.Text
= "2500000"
ElseIf
gol.Text = "IIIC" Then
gaji.Text
= "3500000"
End
If
pinjm.Focus()
End
Sub
End Class
Tidak ada komentar:
Posting Komentar