Selasa, 16 Oktober 2012

program pembelian motor dengan visual basic


Program perhitungan pembelian motor honda
 Tampilan awal

Jika jenis bayar cicil maka bunga 5% per tahun

 
 Cicilan = (Total – DP)/bulan
 
Kode Program
Dim harga, bulan, bunga, total, cicil As Long
Private Sub combo1_click()
Select Case Combo1
Case "beat"
harga = 12000000
Case "revo"
harga = 14500000
Case "tiger"
harga = 21000000
Case "vario"
harga = 13500000
End Select
End Sub

Private Sub Command1_Click()
total = harga
Text4.Text = total
If List1.ListIndex = 0 Then
Text5.Text = 0
Text6.Text = 0
Else
Text5.Enabled = True
Text5.SetFocus
End If
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text5.Enabled = False
List1.ListIndex = 0
Combo1.Text = "Jenis motor"
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()
List1.AddItem "cash"
List1.AddItem "cicil12x"
List1.AddItem "cicil24x"
List1.AddItem "cicil36x"
Combo1.AddItem "beat"
Combo1.AddItem "revo"
Combo1.AddItem "vario"
Combo1.AddItem "tiger"
End Sub

Private Sub list1_click()
bunga = harga * 0.05
Select Case List1
Case "cash"
    harga = harga
Case "cicil12x"
    bulan = 12
    harga = harga + bunga
Case "cicil24x"
    bulan = 24
    harga = harga + bunga * 2
Case "cicil36x"
    bulan = 36
    harga = harga + bunga * 3
End Select
End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cicil = (total - Val(Text5.Text)) / bulan
Text6.Text = cicil
End If
End Sub

1 komentar: