Kamis, 19 April 2012

Tugas VB Pribadi


Tampilan Awal

Soal untuk  Raja laptop
1.       Jika kode kasir di input (di klik) maka akan tampil nama kasir
2.       Tanggal dan waktu akan tampil tanggal dan waktu hari ini
3.       Setelah kita mengisi data kasir berikutnya kita mengisi data penjualan yaitu dengan menginput merk1 (merk laptop) kemudian pilih jenisnya pada cmbmerk2 maka spesifikasi laptop akan terlihat
4.       Jika merk dan jenis laptopnya tidak valid maka akan tampil tulisan “maaf data yang anda masukkan tidak valid, silahkan input data baru”
5.       Jika data yang anda input benar maka harga barang akan keluar
6.       Input jumlah beli
7.       Total harga didapat dari jumlah beli*harga
8.       Diskon di dapat dari total harga*10%
9.       Total bayar didapat dari total harga – diskon yang di dapat
10.   Jika uang bayar < total bayar maka akan keluar tulisan “Maaf Uang Anda Kurang, Silahkan Input Kembali”
11.   Uang kembali di dapat dari uang bayar – total bayar

LISTINGNYA


Private Sub cmbmerk2_Click()
If cmbmerk1.Text = "Axioo" Then
    If cmbmerk2.Text = "Axioo PJM715" Then
    lmerk.Clear
    lmerk.AddItem "ATOM N455/1GB/10,1' "
    lmerk.AddItem "250GB/WIFI/WEB"
    lmerk.AddItem "VGA INTEL 3150M/DOS"
    txtharga = 2225000
    ElseIf cmbmerk2.Text = "Axioo 245M" Then
    lmerk.Clear
    lmerk.AddItem "CORE2DUO 2GHZ/1GB"
    lmerk.AddItem "160GB/14' /WEB/WIFI"
    lmerk.AddItem "DVD-RW/DOS"
    txtharga = 3675000
    Else
    x = MsgBox("Data yang Anda masukkan tidak valid, Silahkan Input data baru", vbinformasi, "Informasi")
    bersih
    End If
ElseIf cmbmerk1.Text = "ACER" Then
    If cmbmerk2.Text = "ACER ASPIRE 4750" Then
    lmerk.Clear
    lmerk.AddItem "CORE i3 2330M/2GB "
    lmerk.AddItem "500GB/14'/DVD-RW"
    lmerk.AddItem "WEB/WIFI/LAN/DOS"
    txtharga = 4560000
    ElseIf cmbmerk2.Text = "ACER 4739-372G32" Then
    lmerk.Clear
    lmerk.AddItem "CORE i3-370/2GB/320GB"
    lmerk.AddItem "14'/DVD-RW/WEB"
    lmerk.AddItem "LAN/WIFI/DOS"
    txtharga = 4060000
    ElseIf cmbmerk2.Text = "ACER ASPIRE 4352" Then
    lmerk.Clear
    lmerk.AddItem "B800/2GB/500GB/14' "
    lmerk.AddItem "DVD-RW/WEB/CR"
    lmerk.AddItem "WIFI/LINUX"
    txtharga = 3540000
    ElseIf cmbmerk2.Text = "ACER Colour 43M" Then
    lmerk.Clear
    lmerk.AddItem "N570/2GB/320GB"
    lmerk.AddItem "10'/WEBCAM"
    lmerk.AddItem "LAN/DOS"
    txtharga = 2560000
    Else
    x = MsgBox("Data yang Anda masukkan tidak valid, Silahkan Input data baru", vbinformasi, "Informasi")
    bersih
    End If
ElseIf cmbmerk1.Text = "Toshiba" Then
    If cmbmerk2.Text = "TOSHIBA NB 520" Then
    lmerk.Clear
    lmerk.AddItem "ATOM N570/2GB/320GB"
    lmerk.AddItem "10'/WEBCAM"
    lmerk.AddItem "WIFI/LAN/DOS"
    txtharga = 3040000
    ElseIf cmbmerk2.Text = "TOSHIBA N7 850" Then
    lmerk.Clear
    lmerk.AddItem "CORE i5-2430M/4GB/500GB"
    lmerk.AddItem "NVIDIA GTS25M 1GB/14'/LAN"
    lmerk.AddItem "DVD-RW/CAM/WIFI/WIN7"
    txtharga = 6510000
    Else
     x = MsgBox("Data yang Anda masukkan tidak valid, Silahkan Input data baru", vbinformasi, "Informasi")
    bersih
    End If
ElseIf cmbmerk1.Text = "SAMSUNG" Then
    If cmbmerk2.Text = "SAMSUNG RV418" Then
    lmerk.Clear
    lmerk.AddItem "CORE i3-2310M/2GB"
    lmerk.AddItem "500GB/14'/DVD-RW"
    lmerk.AddItem "Bluetoth/LAN/DOS"
    txtharga = 4540000
    ElseIf cmbmerk2.Text = "SAMSUNG RC406-A011D" Then
    lmerk.Clear
    lmerk.AddItem "CORE i5-2410M/4GB/500GB"
    lmerk.AddItem "Black/Blue/Red/14'/LAN"
    lmerk.AddItem "DVD-RW/CAM/WIFI/WIN7"
    txtharga = 6800000
    Else
    x = MsgBox("Data yang Anda masukkan tidak valid, Silahkan Input data baru", vbinformasi, "Informasi")
    bersih
    End If
ElseIf cmbmerk1.Text = "ASUS" Then
    If cmbmerk2.Text = "ASUS Eee PC 1215" Then
    lmerk.Clear
    lmerk.AddItem "ATOM/2GB"
    lmerk.AddItem "250GB/10'/DVD-RW"
    lmerk.AddItem "Bluetoth/LAN/6CELL"
    txtharga = 2830000
    ElseIf cmbmerk2.Text = "ASUS A43E COLOUR" Then
    lmerk.Clear
    lmerk.AddItem "CORE i3-2410M/4GB/500GB"
    lmerk.AddItem "Black/Blue/Red/14'/LAN"
    lmerk.AddItem "DVD-RW/CAM/WIFI/DOS"
    txtharga = 6800000
    Else
    x = MsgBox("Data yang Anda masukkan tidak valid, Silahkan Input data baru", vbinformasi, "Informasi")
    bersih
    End If
End If
End Sub


Private Sub cmdcancel_Click()

Call Form_Activate
bersih
End Sub
Pivate Sub cmdinput_Click()
Call Form_Activate
bersih
End Sub

Private Sub cmdkeluar_Click()
x = MsgBox("Anda ingin menutup form ini?", vbQuestion + vbYesNo, "konfirmasi")
If x = vbYes Then
Unload Me
End If
End Sub

Private Sub txtubay_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txttobay.Text = Val(txttohar.Text) - Val(txtdiskon.Text)
    If txtubay.Text < txttobay.Text Then
MsgBox "Maaf Uang Anda Kurang Rp. " & (Val(txttobay.Text) - Val(txtubay.Text)) & "," & "Silahkan Input Kembali", vbOKOnly + vbInformation, "Informasi"
txtubay.Text = ""
txtubay.SetFocus
txtukembali.Text = ""
Else
txtukembali.Text = Val(txtubay) - Val(txttobay)
    End If
End If
End Sub

Private Sub Form_Activate()
bersih
txtwkt.Text = Time
txttgl.Text = Date
cmbmerk1.AddItem "ACER"
cmbmerk1.AddItem "Toshiba"
cmbmerk1.AddItem "ASUS"
cmbmerk1.AddItem "Axioo"
cmbmerk1.AddItem "Samsung"
cmbmerk2.AddItem "TOSHIBA NB 520"
cmbmerk2.AddItem "TOSHIBA N7 850"
cmbmerk2.AddItem "Axioo PJM715"
cmbmerk2.AddItem "Axioo 245M"
cmbmerk2.AddItem "ACER ASPIRE 4750"
cmbmerk2.AddItem "ACER 4739-372G32"
cmbmerk2.AddItem "ACER ASPIRE 4352"
cmbmerk2.AddItem "ACER Colour 43M"
cmbmerk2.AddItem "ASUS Eee PC 1215"
cmbmerk2.AddItem "ASUS A43E COLOUR"
cmbmerk2.AddItem "SAMSUNG RV418"
cmbmerk2.AddItem "SAMSUNG RC406-A011D"
cmdinput.Enabled = True
cmdcancel.Enabled = True
cmdhitung.Enabled = True
cmdkeluar.Enabled = True
End Sub

Sub bersih()
txtnama.Text = ""
txtjumbel.Text = ""
txtdiskon.Text = ""
txttohar.Text = ""
txttobay.Text = ""
txtubay.Text = ""
txtukembali.Text = ""
lmerk.Clear
cmbmerk1.Text = ""
cmbmerk2.Text = ""
lmerk.Text = ""
txtharga.Text = ""
opt1.Value = 0
opt2.Value = 0
opt3.Value = 0
End Sub


Private Sub cmdhitung_Click()
txttohar.Text = txtjumbel * txtharga
If txtjumbel.Text >= 2 Then
txtdiskon.Text = 0.1 * Val(txttohar.Text)
txttobay.Text = Val(txttohar.Text) - Val(txtdiskon.Text)
txtubay.SetFocus
End If
cmdhitung.Enabled = False
cmdcancel.Enabled = True
cmdkeluar.Enabled = True
End Sub

Private Sub opt1_Click()
If opt1.Value = True Then
txtnama.Text = "Reni"
End If
End Sub

Private Sub opt2_Click()
If opt2.Value = True Then
txtnama.Text = "Gita"
End If
End Sub

Private Sub opt3_Click()
If opt3.Value = True Then
txtnama.Text = "Lya"
End If
End Sub

Sub aktif()
bersih
cmbkode.Enabled = True
txtnama.Enabled = True
txtjumbel.Enabled = True
txtdiskon.Enabled = True
txttohar.Enabled = True
txtubay.Enabled = True
txtukembali.Enabled = True
opt1.Enabled = True
opt2.Enabled = True
opt3.Enabled = True
txtharga.Enabled = True
cmbmerk1.Enabled = True
cmbmerk2.Enabled = True
End Sub

Sub nonaktif()
txtnama.Enabled = False
cmbkode.Enabled = False
txtjumbel.Enabled = False
txtdiskon.Enabled = False
txttohar.Enabled = False
txtubay.Enabled = False
txtukembali.Enabled = False
opt1.Enabled = False
opt2.Enabled = False
opt3.Enabled = False
cmbmerk1.Enabled = False
cmbmerk2.Enabled = False
txtharga.Enabled = False
End Sub
 
Tampilan saat penginputan

Tampilan saat memilih merk

Tampilan saat memilih jenis laptop

Tampilan saat jenis laptop yang dipilih tidak sesuai

Karena data tidak valid maka tampilan dibersihkan

Penginputan kembali

Data valid, harga barang muncul

Saat tombol input di klik

Saat uang bayar kurang

uang bayar kosong, input uang lagi

uang kembali keluar

saat tombol input di klik lagi

saat tombol cancel di klik

saat tombol keluar di klik

tampilan di VB



Tugas Pra UTS 2


Tugas Pra UTS 2
Tampilan Awal
 LISTINGNYA............................
Sub aktif()
txtnama.Enabled = True
cmbkode.Enabled = True
opt1.Enabled = True
opt2.Enabled = True
opt3.Enabled = True
txtlama.Enabled = True
txtubay.Enabled = True
End Sub

Sub nonaktif()
txtnama.Enabled = False
cmbkode.Enabled = False
txtjenis.Enabled = False
opt1.Enabled = False
opt2.Enabled = False
opt3.Enabled = False
txtharga.Enabled = False
txtlama.Enabled = False
txttotal.Enabled = False
txtubay.Enabled = False
txtukem.Enabled = False
txttgl.Enabled = False
End Sub

Sub bersih()
txtnama.Text = ""
cmbkode.Text = ""
txtjenis.Text = ""
opt1.Value = 0
opt2.Value = 0
opt3.Value = 0
txtharga.Text = ""
txtlama.Text = ""
txttotal.Text = ""
txtubay.Text = ""
txtukem.Text = ""
End Sub

Private Sub Form_Activate()
nonaktif
bersih
txttgl.Text = Date
cmbkode.AddItem "SU01"
cmbkode.AddItem "BS01"
cmbkode.AddItem "PR01"
cmdisi.Enabled = True
cmdkeluar.Enabled = True
End Sub

Private Sub cmbkode_Click()
If cmbkode.Text = "SU01" Then
txtjenis.Text = "Suit"
ElseIf cmbkode.Text = "BS01" Then
txtjenis.Text = "Bussines"
Else
txtjenis.Text = "President"
End If
End Sub

Private Sub cmdisi_Click()
aktif
bersih
txtnama.SetFocus
cmbkode.Text = "-Pilih-"
cmdisi.Enabled = True
cmdkeluar.Enabled = True
End Sub

Private Sub cmdkeluar_Click()
X = MsgBox("Tutup Form?", vbYesNo + vbQuestion, "konfirmasi")
If X = vbYes Then
Unload Me
End If
End Sub

Private Sub opt1_Click()
If opt1.Value = True And txtjenis.Text = "Suit" Then
txtharga.Text = 300000
ElseIf opt1.Value = True And txtjenis.Text = "Bussines" Then
txtharga.Text = 500000
Else
txtharga.Text = 800000
End If
txtlama.SetFocus
End Sub

Private Sub opt2_Click()
If opt2.Value = True And txtjenis.Text = "Suit" Then
txtharga.Text = 400000
ElseIf opt2.Value = True And txtjenis.Text = "Bussines" Then
txtharga.Text = 600000
Else
txtharga.Text = 900000
End If
txtlama.SetFocus
End Sub

Private Sub opt3_Click()
If opt3.Value = True And txtjenis.Text = "Suit" Then
txtharga.Text = 500000
ElseIf opt3.Value = True And txtjenis.Text = "Bussines" Then
txtharga.Text = 7000000
Else
txtharga.Text = 1000000
End If
txtlama.SetFocus
End Sub
Private Sub txtlama_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txttotal.Text = Val(txtharga.Text) * Val(txtlama.Text)
End If
End Sub

Private Sub txttotal_Change()
txtubay.SetFocus
End Sub

Private Sub txtubay_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    Val (txttotal.Text) - Val(txtubay.Text)
If txtubay.Text < txttotal.Text Then
MsgBox "Maaf Uang Anda Kurang Rp. " & (Val(txttotal.Text) - Val(txtubay.Text)) & "," & "Silahkan Input Kembali", vbOKOnly + vbInformation, "Informasi"
txtubay.Text = ""
txtubay.SetFocus
txtukem.Text = ""
Else
txtukem.Text = Val(txtubay.Text) - Val(txttotal.Text)
End If
cmdisi.Enabled = True
End If
End Sub

Private Sub txtukem_Change()
If Val(txtukem.Text) < 0 Then
txtukem.Enabled = "False"
End If
End Sub

Saat di Input
Saat tombol input di klik lagi

Saat uang bayar kurang


Saat uang bayar di isi kembali

Saat tombol keluar di klik