Kamis, 27 Oktober 2011

Program Visual Basic Pemesanan Tiket Pesawat

Posted by Unknown On Kamis, Oktober 27, 2011 | 2 comments

Sintaknya :

Dim i, jumlah As Variant

Private Sub Timer1_Timer()
tanggal = Format(Date, "dddd,d mmmm yyyy")
waktu = Format(Time, "hh:mm:ss")
End Sub

Private Sub Form_Activate()
cmbdari.Text = "--Pilih--"
cmbke.Text = "--Pilih--"
cmbhari.Text = "--Tanggal--"
cmbbulan.Text = "--Bulan--"
cmbtahun.Text = "--Tahun--"
cmbhari1.Text = "--Tanggal--"
cmbbulan1.Text = "--Bulan--"
cmbtahun1.Text = "--Tahun--"
For i = 1 To 31
Me.cmbhari.AddItem (Str(i))
Next i
For i = 1 To 12
Me.cmbbulan.AddItem (MonthName(i))
Next i
For i = 2010 To 2020
Me.cmbtahun.AddItem (Str(i))
Next i
For i = 1 To 31
Me.cmbhari1.AddItem (Str(i))
Next i
For i = 1 To 12
Me.cmbbulan1.AddItem (MonthName(i))
Next i
For i = 2010 To 2020
Me.cmbtahun1.AddItem (Str(i))
Next i
cmbdari.AddItem "Jakarta (CGK)"
cmbdari.AddItem "Denpasar (DPS)"
cmbdari.AddItem "Surabaya (SBY)"
cmbke.AddItem "Jakarta (CGK)"
cmbke.AddItem "Denpasar (DPS)"
cmbke.AddItem "Surabaya (SBY)"
txtnama.SetFocus
End Sub

Private Sub cmbtahunk_Click()
If cmbhari1.Text < cmbhari.Text Or cmbtahun1.Text < cmbtahun.Text Then
MsgBox "Tanggal Kembali Tidak Boleh Melebihi Tanggal Berangkat", vbInformation, "WARNING!"
End If
End Sub

Private Sub Option1_Click()
If cmbdari.ListIndex = 0 And cmbke.ListIndex = 1 Then
txtharga.Text = 1855000
ElseIf cmbdari.ListIndex = 0 And cmbke.ListIndex = 2 Then
txtharga.Text = 1200000
ElseIf cmbdari.ListIndex = 1 And cmbke.ListIndex = 0 Then
txtharga.Text = 1700000
ElseIf cmbdari.ListIndex = 2 And cmbke.ListIndex = 0 Then
txtharga.Text = 1055000
Else
MsgBox "Kota Asal Dan Kota Tujuan Tidak Boleh Sama", vbInformation, "WARNING!"
End If
End Sub

Private Sub Option2_Click()
If cmbdari.ListIndex = 0 And cmbke.ListIndex = 1 Then
txtharga.Text = 1050000
ElseIf cmbdari.ListIndex = 0 And cmbke.ListIndex = 2 Then
txtharga.Text = 750000
ElseIf cmbdari.ListIndex = 1 And cmbke.ListIndex = 0 Then
txtharga.Text = 900000
ElseIf cmbdari.ListIndex = 2 And cmbke.ListIndex = 0 Then
txtharga.Text = 600000
Else
MsgBox "Kota Asal Dan Kota Tujuan Tidak Boleh Sama", vbInformation, "WARNING!"
End If
End Sub

Dim harga, dewasa, bayi, hargabayi, subtotal, total As Currency

Private Sub Check1_Click()
dewasa = txtdewasa.Text
bayi = txtbayi.Text
harga = txtharga.Text
hargabayi = 0.15 * harga
bagasi = 30000
subtotal = (dewasa * harga) + (hargabayi * bayi)
total = subtotal + bagasi
txttotal.Text = subtotal
txttobay.Text = total
txtcash.SetFocus
End Sub

Private Sub Check2_Click()
dewasa = txtdewasa.Text
bayi = txtbayi.Text
harga = txtharga.Text
hargabayi = 0.15 * harga
bagasi = 60000
subtotal = (dewasa * harga) + (hargabayi * bayi)
total = subtotal + bagasi
txttotal.Text = subtotal
txttobay.Text = total
txtcash.SetFocus
End Sub

Private Sub Check3_Click()
dewasa = txtdewasa.Text
bayi = txtbayi.Text
harga = txtharga.Text
hargabayi = 0.15 * harga
bagasi = 90000
subtotal = (dewasa * harga) + (hargabayi * bayi)
total = subtotal + bagasi
txttotal.Text = subtotal
txttobay.Text = total
txtcash.SetFocus
End Sub

Private Sub txtcash_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtkembali.Text = Val(txtcash.Text) - Val(txttobay.Text)
End If
End Sub

Private Sub cmdclear_Click()
cmbdari.Text = "--Pilih--"
cmbke.Text = "--Pilih--"
cmbhari.Text = "--Tanggal--"
cmbbulan.Text = "--Bulan--"
cmbtahun.Text = "--Tahun--"
cmbhari1.Text = "--Tanggal--"
cmbbulan1.Text = "--Bulan--"
cmbtahun1.Text = "--Tahun--"
txtnama.Text = " "
txttelepon.Text = " "
Option1.Value = False
Option2.Value = False
Check1.Value = 0
Check2.Value = 0
Check3.Value = 0
txtharga.Text = " "
txtdewasa.Text = " "
txtbayi.Text = " "
txttotal.Text = " "
txttobay.Text = " "
txtcash.Text = " "
txtkembali.Text = " "
txtnama.SetFocus
End Sub

Private Sub cmdexit_Click()
X = MsgBox("Are Your Sure To Exit?", vbQuestion + vbYesNoCancel, "Konfirmasi")
If X = vbYes Then
End
End If
End Sub

2 komentar:

Blog Archive

Blogroll