“Everybody in this country should learn to program a computer, because it teaches you how to think.”

Masukkan Kata Kunci Pencarian Anda Disini

Tuesday 10 May 2011

Program Menghitung Jumlah Diskon dengan VB 6.0

*______*

Setalah kemarin share tentang Program Menghitung Gaji
Kini saya akan berbagi lagi, yaitu tentang Cara Menghitung Diskon.

Seperti biasa buka program VB 6.0

Kemudian masukkan beberapa masukkan beberapa Object separti < Label, Text Box, Command Button, Timer >
Kemudian atur propertisnya.
Contoh :



Kemudian masuk ke menu program,
masukan code di bawah ini:

Private Sub Cmd1_Click()
Dim bayar, tunai, potongan, kembali As Currency

harga = Txt1.Text
Txt1.Text = "" & Format(Txt1.Text, "Currency")
Select Case harga

Case Is = ""
MsgBox "Anda Belum Memasukkan Harga", vbInformation, "Yuwono-TI"
Txt1.SetFocus
Exit Sub

Case Is <= 24999 potongan = harga * 0 Lbl2.Caption = "Anda Menghemat : " & Format(potongan, "Currency") Lbl1.Caption = "Discount = 0%" bayar = harga - potongan Lbl3.Caption = "Total Bayar : " & Format(bayar, "Currency") Cmd2.Enabled = True Txt2.Visible = True Txt2.SetFocus Case 25000 To 99999 potongan = harga * 0.05 Lbl2.Caption = "Anda Menghemat : " & Format(potongan, "Currency") Lbl1.Caption = "Discount = 5%" bayar = harga - potongan Lbl3.Caption = "Total Bayar : " & Format(bayar, "Currency") Cmd2.Enabled = True Txt2.Visible = True Txt2.SetFocus Case 100000 To 149999 potongan = harga * 0.1 Lbl2.Caption = "Anda Menghemat : " & Format(potongan, "Currency") Lbl1.Caption = "Discount = 10%" bayar = harga - potongan Lbl3.Caption = "Total Bayar : " & Format(bayar, "Currency") Cmd2.Enabled = True Txt2.Visible = True Txt2.SetFocus Case 150000 To 249999 potongan = harga * 0.15 Lbl2.Caption = "Anda Menghemat : " & Format(potongan, "Currency") Lbl1.Caption = "Discount = 15%" bayar = harga - potongan Lbl3.Caption = "Total Bayar : " & Format(bayar, "Currency") Cmd2.Enabled = True Txt2.Visible = True Txt2.SetFocus Case Else potongan = harga * 0.2 Lbl2.Caption = "Anda Menghemat : " & Format(potongan, "Currency") Lbl1.Caption = "Discount = 20%" bayar = harga - potongan Lbl3.Caption = "Total Bayar : " & Format(bayar, "Currency") Cmd2.Enabled = True Txt2.Visible = True Txt2.SetFocus End Select Cmd1.Enabled = False Cmd4.Enabled = True Cmd4.Default = True Lbl2.Visible = True Lbl3.Visible = True Lbl4.Visible = False Lbl6.Visible = True End Sub Private Sub Cmd2_Click() Lbl2.Caption = "Anda Menghemat : Rp0 " & Format(potongan, "Currency") Lbl1.Caption = " Discount = 0%" Lbl3.Caption = "Total Bayar : Rp0" & Format(bayar, "Currency") Lbl4.Caption = "Kembali : Rp0" & Format(kembali, "Currency") Lbl5.Visible = False Lbl2.Visible = False Lbl3.Visible = False Lbl4.Visible = False Lbl6.Visible = False Txt1.Text = "" Txt2.Text = "" Txt2.Visible = False Cmd1.Enabled = True Cmd2.Enabled = False Cmd4.Enabled = False Txt1.SetFocus Cmd1.Default = True End Sub Private Sub Cmd3_Click() Dim nPil As Integer nPil = MsgBox("Apakah Anda Yakin", vbYesNo) If nPil = vbYes Then Close #1 Cancel = 0 Unload Me Else Cancel = 1 End If End Sub Private Sub Cmd4_Click() Dim bayar, tunai, potongan, kembali As Currency harga = Txt1.Text Txt1.Text = "" & Format(Txt1.Text, "Currency") Select Case harga Case Is = "" MsgBox "Anda Belum Memasukkan Harga", vbInformation, "Yuwono-TI" Txt1.SetFocus Exit Sub Case Is <= 24999 potongan = harga * 0 Lbl2.Caption = "Anda Menghemat : " & Format(potongan, "Currency") Lbl1.Caption = "Discount = 0%" bayar = harga - potongan Lbl3.Caption = "Total Bayar : " & Format(bayar, "Currency") tunai = Txt2.Text Txt2.Text = "" & Format(Txt2.Text, "Currency") Select Case tunai Case Is = "" MsgBox "Anda Belum Membayar", vbInformation, "Yuwono-TI" Txt2.SetFocus Exit Sub End Select kembali = Txt2.Text - bayar Lbl4.Caption = "Kembali : " & Format(kembali, "Currency") Case 25000 To 99999 potongan = harga * 0.05 Lbl2.Caption = "Anda Menghemat : " & Format(potongan, "Currency") Lbl1.Caption = "Discount = 5%" bayar = harga - potongan Lbl3.Caption = "Total Bayar : " & Format(bayar, "Currency") tunai = Txt2.Text Txt2.Text = "" & Format(Txt2.Text, "Currency") Select Case tunai Case Is = "" MsgBox "Anda Belum Membayar", vbInformation, "Yuwono-TI" Txt2.SetFocus Exit Sub End Select kembali = Txt2.Text - bayar Lbl4.Caption = "Kembali : " & Format(kembali, "Currency") Case 100000 To 149999 potongan = harga * 0.1 Lbl2.Caption = "Anda Menghemat : " & Format(potongan, "Currency") Lbl1.Caption = "Discount = 10%" bayar = harga - potongan Lbl3.Caption = "Total Bayar : " & Format(bayar, "Currency") tunai = Txt2.Text Txt2.Text = "" & Format(Txt2.Text, "Currency") Select Case tunai Case Is = "" MsgBox "Anda Belum Membayar", vbInformation, "Yuwono-TI" Txt2.SetFocus Exit Sub End Select kembali = Txt2.Text - bayar Lbl4.Caption = "Kembali : " & Format(kembali, "Currency") Case 150000 To 249999 potongan = harga * 0.15 Lbl2.Caption = "Anda Menghemat : " & Format(potongan, "Currency") Lbl1.Caption = "Discount = 15%" bayar = harga - potongan Lbl3.Caption = "Total Bayar : " & Format(bayar, "Currency") tunai = Txt2.Text Txt2.Text = "" & Format(Txt2.Text, "Currency") Select Case tunai Case Is = "" MsgBox "Anda Belum Membayar", vbInformation, "Yuwono-TI" Txt2.SetFocus Exit Sub End Select kembali = Txt2.Text - bayar Lbl4.Caption = "Kembali : " & Format(kembali, "Currency") Case Else potongan = harga * 0.2 Lbl2.Caption = "Anda Menghemat : " & Format(potongan, "Currency") Lbl1.Caption = "Discount = 20%" bayar = harga - potongan Lbl3.Caption = "Total Bayar : " & Format(bayar, "Currency") tunai = Txt2.Text Txt2.Text = "" & Format(Txt2.Text, "Currency") Select Case tunai Case Is = "" MsgBox "Anda Belum Membayar", vbInformation, "Yuwono-TI" Txt2.SetFocus Exit Sub End Select kembali = Txt2.Text - bayar Lbl4.Caption = "Kembali : " & Format(kembali, "Currency") End Select Cmd4.Enabled = False If Txt2.Text = "" Then Cmd4.Enabled = True End If Cmd2.Default = True Lbl4.Visible = True Lbl5.Visible = True End Sub Private Sub Form_Load() Cmd1.Enabled = True Cmd2.Enabled = False Cmd3.Enabled = True Cmd4.Enabled = False Lbl2.Caption = "Anda Menghemat : Rp0 " & Format(potongan, "Currency") Lbl2.Visible = False Lbl1.Caption = " Discount = 0%" Lbl3.Caption = "Total Bayar : Rp0" & Format(bayar, "Currency") Lbl3.Visible = False Lbl4.Caption = "Kembali : Rp0" & Format(kembali, "Currency") Lbl4.Visible = False Lbl5.Visible = False Lbl6.Visible = False Txt1.Text = "" Txt2.Text = "" Txt2.Visible = False End Sub Private Sub Timer1_Timer() Lbl7.Caption = "Jam : " & Format(Now(), "HH:mm:ss") Lbl8.Caption = hariini() & ", " & Format(Date, "dd mmmm yyyy") End Sub Private Function hariini() As String Dim sHari As String Dim ar() ar = Array("", "Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu") hariini = ar(Weekday(Now)) sHari = ar(Abs(Weekday(Date) - 1)) End Function Setelah di Running akan tampil seperti ini:





Selamat mencoba.
Atau anda bisa juga mendownload langsung disini.

1 comment:

Gunakan bahasa yang baik dan sopan. Komentar yang berbau SARA akan di HAPUS / DELETE.
Komentar akan muncul setelah mendapat persetujuan dari Admin Anak Rantau.