4. Penjualan_Komputer (With DBGrid)

NAMA : RINI ASTUTI (11100113)

1. ENTRI PENJUALAN KOMPUTER

KODE PROGRAM

Private Sub Cmbkode_Click()
Dim kode, JK, HS As String

Select Case Cmbkode.Text
Case “P205”
txtJK.Text = “Pentium II 500 Mega Hz”
TxtHS.Text = “1500000”
Case “P308”
txtJK.Text = “Pentium III 800 Mega Hz”
TxtHS.Text = “2100000”
Case “P310”
txtJK.Text = “Pentium III 1.0 Giga Hz”
TxtHS.Text = “3500000”
Case “P415”
txtJK.Text = “Pentium IV 1.5 Giga Hz”
TxtHS.Text = “4000000”
Case “P417”
txtJK.Text = “Pentium IV 1.7 Giga Hz”
TxtHS.Text = “4200000”
Case “P419”
txtJK.Text = “Pentium IV 1.9 Giga Hz”
TxtHS.Text = “5500000”
End Select
TxtJJ.SetFocus
End Sub

Private Sub Cmdclose_Click()
Unload Me
End Sub

Private Sub Cmdproses_Click()
Dim HP, HS, Dis, HB As String

TxtHP.Text = Val(TxtJJ.Text) * Val(TxtHS.Text)
HP = TxtHP.Text

If HP > “30000000” Then
Txtdis.Text = 0.15 * HP
ElseIf HP > “25000000” Then
Txtdis.Text = 0.1 * HP
ElseIf HP > “20000000” Then
Txtdis.Text = 0.05 * HP
ElseIf HP > “15000000” Then
Txtdis.Text = 0.02 * HP
End If

TxtHB.Text = Val(TxtHP.Text) – Val(Txtdis.Text)
TxtHB.SetFocus
End Sub

Private Sub Cmdsave_Click()
Data1.Refresh
With Data1.Recordset
.AddNew
.Fields(“KODE”) = Cmbkode.Text
.Fields(“JENIS_KOMPUTER”) = txtJK.Text
.Fields(“HARGA_SATUAN”) = TxtHS.Text
.Fields(“JUMLAH_JUAL”) = TxtJJ.Text
.Fields(“HARGA_PENJUALAN”) = TxtHP.Text
.Fields(“DISCOUNT”) = Txtdis.Text
.Fields(“HARGA_BAYAR”) = TxtHB.Text
.Update
End With
Cmbkode.Enabled = True
Cmbkode = “”
txtJK = “”
TxtHS = “”
TxtJJ = “”
TxtHP = “”
Txtdis = “”
TxtHB = “”
Cmbkode.SetFocus
End Sub

Private Sub Form_Load()
Cmbkode.AddItem “P205”
Cmbkode.AddItem “P308”
Cmbkode.AddItem “P310”
Cmbkode.AddItem “P415”
Cmbkode.AddItem “P417”
Cmbkode.AddItem “P419”
End Sub

Private Sub TxtHB_Change()
Txtterbilang.Text = terbilang(Val(TxtHB.Text))

End Sub
Private Function baca(X As Integer) As String
Dim i As Long
Dim ratus(9) As String
Dim belas(9) As String
Dim puluh(9) As String
Dim satuan(9) As String
Dim sbaca As String
satuan(1) = “satu”
satuan(2) = “dua”
satuan(3) = “tiga”
satuan(4) = “empat”
satuan(5) = “lima”
satuan(6) = “enam”
satuan(7) = “tujuh”
satuan(8) = “delapan”
satuan(9) = “sembilan”

For i = 1 To 9
If i = 1 Then
puluh(i) = “sepuluh”
Else
puluh(i) = satuan(i) & ” puluh”
End If

Next
For i = 1 To 9
If i = 1 Then
belas(i) = “sebelas”
Else
belas(i) = satuan(i) & ” belas”
End If

Next
For i = 1 To 9
If i = 1 Then
ratus(i) = “seratus”
Else
ratus(i) = satuan(i) & ” ratus”
End If

Next
If X >= 100 Then
sbaca = ratus(Val(Mid(Str(X), 2, 1)))
X = Val(Mid(Str(X), 3, 2))
End If

If X >= 20 Or X = 10 Then
sbaca = sbaca & ” ” & puluh(Val(Mid(Str(X), 2, 1)))
X = Val(Mid(Str(X), 3, 1))
Else
If X > 10 Then
sbaca = sbaca & ” ” & belas(Val(Mid(Str(X), 3, 1)))
X = -1
End If
End If

If X >= 1 Then
sbaca = sbaca & ” ” & satuan(Val((Str(X))))
End If
baca = sbaca

End Function
Function terbilang(X As Currency) As String
Dim ribu, juta, milyar, trilyun, ratusan As Integer
Dim sterbilang As String
Dim ptext As Byte

sterbilang = “”
If Val(X) = 1000000000000# Then
ptext = Len(Str(X)) – 13
trilyun = Val(Mid(Str(X), 2, ptext))
sterbilang = sterbilang & ” ” & baca(Val(trilyun)) & ” trilyun”
X = Val(Mid(Str(X), ptext + 2, 12))
End If

If X >= 1000000000 Then
ptext = Len(Str(X)) – 10
milyar = Val(Mid(Str(X), 2, ptext))
sterbilang = sterbilang & ” ” & baca(Val(milyar)) & ” milyar”
X = Val(Mid(Str(X), ptext + 2, 9))
End If

If X >= 1000000 Then
ptext = Len(Str(X)) – 7
juta = Val(Mid(Str(X), 2, ptext))
sterbilang = sterbilang & ” ” & baca(Val(juta)) & ” juta”
X = Val(Mid(Str(X), ptext + 2, 6))
End If

If X >= 1000 Then
ptext = Len(Str(X)) – 4
ribu = Val(Mid(Str(X), 2, ptext))
If ribu = 1 Then
sterbilang = “seribu”
Else
sterbilang = sterbilang & ” ” & baca(Val(ribu)) & ” ribu”
End If

X = Val(Mid(Str(X), ptext + 2, 3))
End If
sterbilang = sterbilang & ” ” & baca(Val(X))
terbilang = Trim(sterbilang) & ” rupiah”
End Function

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

  • %d bloggers like this: