Minggu, 11 Januari 2015

Program visual basic menghitung total bayar menggunakan diskon

By Wie 


























Code programnya :

Dim a As Currency
Dim b As Currency
Dim c As Currency
Dim d As Currency
Dim e As Currency
Dim belanja As Currency
Dim dis As Currency
Dim bayar As Currency
Dim jam As Double

Private Sub Command2_Click()
Form1.Show
Unload Me
End Sub

Private Sub Form_Load()
Text7.Enabled = False
Text8.Enabled = False
Text9.Enabled = False
Text10.Enabled = False
End Sub

Private Sub Command1_Click()
jam = Text1.Text
a = Text2.Text
b = Text3.Text
c = Text4.Text
d = Text5.Text
e = Text6.Text

belanja = a + b + c + d + e
Text7.Text = belanja

If jam < 15.1 Then
    If belanja > 300000 Then
        dis = belanja * (15 / 100)
        Text8.Text = "15%"
        Text9.Text = dis
        Command1.Enabled = False
        ElseIf belanja > 200000 Then
        dis = belanja * (10 / 100)
        Text8.Text = "10%"
        Text9.Text = dis
        Command1.Enabled = False
        ElseIf belanja > 100000 Then
        dis = belanja * (5 / 100)
        Text8.Text = "5%"
        Text9.Text = dis
        Command1.Enabled = False
        Else
        dis = 0
        Text8.Text = 0
        Text9.Text = dis
        Command1.Enabled = False
    End If
Else
    dis = 0
    Text8.Text = 0
    Text9.Text = dis
    Command1.Enabled = False
End If
If jam > 7.9 Then
    If belanja > 300000 Then
        dis = belanja * (15 / 100)
        Text8.Text = "15%"
        Text9.Text = dis
        Command1.Enabled = False
        ElseIf belanja > 200000 Then
        dis = belanja * (10 / 100)
        Text8.Text = "10%"
        Text9.Text = dis
        Command1.Enabled = False
        ElseIf belanja > 100000 Then
        dis = belanja * (5 / 100)
        Text8.Text = "5%"
        Text9.Text = dis
        Command1.Enabled = False
        Else
        dis = 0
        Text8.Text = 0
        Text9.Text = dis
        Command1.Enabled = False
    End If
Else
    dis = 0
    Text8.Text = 0
    Text9.Text = dis
    Command1.Enabled = False
End If

bayar = belanja - dis
Text10.Text = bayar
End Sub

Salam ilmu pengetahuan ^^

Tidak ada komentar:

Posting Komentar