Tampilkan postingan dengan label Materi Kuliah. Tampilkan semua postingan
Tampilkan postingan dengan label Materi Kuliah. Tampilkan semua postingan

Selasa, 26 Januari 2010

Program Hotel ( Visual Basic )





Dim fasilitas, tv, internet, sewa, total, bayar, kembali As Long


Private Sub Check1_Click()
If Check1.Value = 1 Then
internet = 200000
Else
internet = 0
End If
hitung
End Sub

Private Sub Check2_Click()
If Check2.Value = 1 Then
tv = 100000
Else
internet = 0
End If
hitung
End Sub




Private Sub Combo1_Click()
If Combo1.Text = "S001" Then
Text2.Text = "Single Bad"
ElseIf Combo1.Text = "D001" Then
Text2.Text = "Double Bad"
End If
End Sub

Private Sub Command1_Click()
Text1.Text = ""
Combo1.Text = ""
Text2.Text = ""
Option1.Value = False
Option2.Value = False
Option3.Value = False
Check1.Value = False
Check2.Value = False
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
End Sub

Private Sub Command2_Click()
Dim pesan As String
pesan = MsgBox("yakin Anda akan keluar?", vbYesNo, "KONFIRMASI")
If pesan = vbYes Then
End
End If
End Sub

Private Sub Form_Load()
'untuk menambahakan kode kamar di combo 1
Combo1.AddItem "S001"
Combo1.AddItem "D001"
End Sub

Private Sub Option1_Click()
If Combo1.Text = "S001" Then
sewa = 1000000
ElseIf Combo1.Text = "D001" Then
sewa = 1200000
Else
sewa = 0
End If
Text3.Text = Format(sewa, "currency")
End Sub

Private Sub Option2_Click()
If Combo1.Text = "S001" Then
sewa = 900000
ElseIf Combo1.Text = "D001" Then
sewa = 1000000
Else
sewa = 0
End If
Text3.Text = Format(sewa, "currency")
End Sub

Private Sub Option3_Click()
If Combo1.Text = "S001" Then
sewa = 800000
ElseIf Combo1.Text = "D001" Then
sewa = 900000
Else
sewa = 0
End If
Text3.Text = Format(sewa, "currency")
End Sub

Sub hitung()
fasilitas = tv + internet
Text4.Text = Format(fasilitas, "currency")
total = fasilitas + sewa
Text5.Text = Format(total, "currency")
Text6.SetFocus

End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
bayar = Text6.Text
Text6.Text = Format(bayar, "currency")
kembali = bayar - total
Text7.Text = Format(kembali, "currency")
End If

End Sub









Program Kalkulator ( Visual Basic )


Beriku Logika pembuatannya :


Private Sub Bagi_Click()
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End Sub


Private Sub Command1_Click()
'contoh tanpa variabel
Text3.Text = Val(Text1.Text) + Val(Text2.Text)


End Sub

Private Sub Command2_Click()
'Contoh menggunakan variabel
Dim bilangan1 As Integer
Dim bilangan2 As Integer
Dim hasil As Integer
bilangan1 = Text1.Text
bilangan2 = Text2.Text
hasil = bilangan1 - bilangan2
Text3.Text = hasil
End Sub

Private Sub Kali_Click()
Text3.Text = Val(Text1.Text) * Val(Text2.Text)

End Sub

Private Sub Label4_Click()

End Sub











Menghitung Nilai ( Visual Basic )



Berikut Logika pembuatannya :

Private Sub Command1_Click()
Dim tugas, quis, uts, uas As Integer
tugas = Text1.Text
quis = Text2.Text
uts = Text3.Text
uas = Text4.Text
akhir = (tugas * 0.2) + (quis * 0.2) + (uts * 0.3) + (uas * 0.3)
Text5.Text = akhir

If akhir >= 90 Then
Text6.Text = "Nilai A"
ElseIf akhir >= 75 And akhir <= 89 Then Text6.Text = "Nilai B" ElseIf akhir >= 60 And akhir <= 74 Then Text6.Text = "Nilai C" ElseIf akhir >= 50 And akhir <= 59 Then Text6.Text = "Nilai D" Else Text6.Text = "ERROR" End If End Sub Private Sub Command2_Click() 'untuk membersihkan textox Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = "" Text1.SetFocus End Sub Private Sub Command3_Click() End End Sub Private Sub Form_Load() End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) 'fungsi enter \ pada saat dienter maka akan fokus ke text2 If KeyAscii = 13 Then Text2.SetFocus End If End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) 'fungsi enter \ pada saat dienter maka akan fokus ke text2 If KeyAscii = 13 Then Text3.SetFocus End If End Sub Private Sub Text3_KeyPress(KeyAscii As Integer) 'fungsi enter \ pada saat dienter maka akan fokus ke text2 If KeyAscii = 13 Then Text4.SetFocus End If End Sub Private Sub Text5_KeyPress(KeyAscii As Integer) 'fungsi enter \ pada saat dienter maka akan fokus ke text2 If KeyAscii = 13 Then Text5.SetFocus End If End Sub Private Sub Text6_KeyPress(KeyAscii As Integer) 'fungsi enter \ pada saat dienter maka akan fokus ke text2 If KeyAscii = 13 Then Text5.SetFocus End If End Sub