Rabu, 26 September 2012

VISUAL BASIC cara mengasihkan discount

Private Sub Form_Activate()
Dim kode(100), tema(100), jumlah(100), HargaPerSatuan(100), Discont(100), Dist(100), Dispros(100), Bayar1(100), Bayar2(100), i, n, m, TotalBayar

TotalBayar = 0

Form1.Print "============================================================================"
    Print
    Form1.Print Tab(5); "Kode";
    Form1.Print Tab(15); "Tema";
    Form1.Print Tab(35); "Jumlah";
    Form1.Print Tab(45); "Harga Per Satuan";
    Form1.Print Tab(70); "Discount";
    Form1.Print Tab(85); "Bayar";
    Print
    Form1.Print "============================================================================"
    Print

n = InputBox("Masukkan Jumlah Banyaknya Data ")
For m = 1 To n
    kode(i) = InputBox("Masukkan Kode (A-E)")
    jumlah(i) = InputBox("Masukkan Jumlah Yang Dibeli")
    HargaPerSatuan(i) = InputBox("Masukkan Harga Per Satuan")
   
    If kode(i) = "A" Then
        tema(i) = "Komputer"
    ElseIf kode(i) = "B" Then
        tema(i) = "Ekonomi"
    ElseIf kode(i) = "C" Then
        tema(i) = "Akuntansi"
    ElseIf kode(i) = "D" Then
        tema(i) = "Statistik"
    ElseIf kode(i) = "E" Then
        tema(i) = "Umum"
    End If
   
          
    If jumlah(i) <= 10 Then
        Dist(i) = "5%"
        Discont(i) = 0.05
       
    ElseIf jumlah(i) <= 20 Then
        Dist(i) = "10%"
        Discont(i) = 0.1
       
    ElseIf jumlah(i) <= 30 Then
        Dist(i) = "15%"
        Discont(i) = 0.15
       
    ElseIf jumlah(i) <= 40 Then
        Dist(i) = "20%"
        Discont(i) = 0.2
       
    ElseIf jumlah(i) > 40 Then
        Dist(i) = "25%"
        Discont(i) = 0.25
    End If
   
   
    Bayar1(i) = jumlah(i) * HargaPerSatuan(i)
    Dispros(i) = Bayar1(i) * Discont(i)
    Bayar2(i) = Bayar1(i) - Dispros(i)
    TotalBayar = TotalBayar + Bayar2(i)
   
    Form1.Print Tab(5); kode(i);
    Form1.Print Tab(15); tema(i);
    Form1.Print Tab(35); jumlah(i);
    Form1.Print Tab(45); Format(HargaPerSatuan(i), "Rp ###,###,###");
    Form1.Print Tab(70); Dist(i);
    Form1.Print Tab(85); Format(Bayar2(i), "Rp ###,###,###");
    Print
Next m
Form1.Print "-------------------------------------------------------------------------------------------------------------------------------------------------------"
Print
    Form1.Print Tab(85); "TotalBayar";
Print
Print
    Form1.Print Tab(85); Format(TotalBayar, "Rp ###,###,###");

End Sub

Tidak ada komentar:

Posting Komentar