Kamis, 24 November 2011

Kumpulan Listing Program VB


1. PROGRAM PASSWORD

Private Sub Command1_Click()
If PWD.Text = "BUNGA" Then
MsgBox "PASSWORD ANDA BENAR", vbOKOnly, "PERHATIAN"
Form2.Show
Form1.Hide
Else
MsgBox "PASSWORD ANDA SALAH", vbOKOnly + vbCritical, "WARNING"
PWD.Text = ""
PWD.SetFocus
End If
End Sub


2. PROGRAM KALKULATOR

Private Sub Command1_Click()
HASIL = Val(Text1.Text) + Val(Text2.Text)
End Sub

Private Sub Command2_Click()
HASIL = Val(Text1.Text) - Val(Text2.Text)
End Sub

Private Sub Command3_Click()
HASIL = Val(Text1.Text) * Val(Text2.Text)
End Sub

Private Sub Command4_Click()
HASIL = Val(Text1.Text) / Val(Text2.Text)
End Sub

Private Sub Command5_Click()
Text1.Text = ""
Text2.Text = ""
HASIL = ""
End Sub

Private Sub Command6_Click()
Form2.Show
Form5.Hide
End Sub



3. PROGRAM MENU PILIHAN

Private Sub Command2_Click()
Unload Me
End Sub


Private Sub Command1_Click()
Form3.Show
Form2.Hide
End Sub

Private Sub Command2_Click()
Form4.Show
Form2.Hide
End Sub

Private Sub Command3_Click()
Form5.Show
Form2.Hide
End Sub

Private Sub Command4_Click()
Form6.Show
Form2.Hide
End Sub

Private Sub Command5_Click()
Form7.Show
Form2.Hide
End Sub

Private Sub Command6_Click()
Form8.Show
Form2.Hide
End Sub

Private Sub Command7_Click()
Form9.Show
Form2.Hide
End Sub

Private Sub Command8_Click()
Form1.Show
Form2.Hide
End Sub


4. PROGRAM LUAS PERSEGI PANJANG

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

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Command4_Click()
Form2.Show
Form3.Hide
End Sub



5. PROGRAM  LUAS LINGKARAN

Private Sub Command1_Click()
Text2.Text = 3.14 * Val(Text1.Text) * Val(Text1.Text)
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Command4_Click()
Form2.Show
Form4.Hide
End Sub



6. PROGRAM BELAJAR MENGHITUNG

Dim JUMLAH As Integer
Dim ISI As Integer
Dim TULISANSKOR As String
Dim TOTALSKOR As Integer

Private Sub Command1_Click()
JUMLAH = CInt(Label1.Caption) + CInt(Label3.Caption)
If (Text1.Text = "") Then
Text1.Text = "0"
ISI = 0
Else
ISI = CInt(Text1.Text)
End If
If ISI = JUMLAH Then
Label5 = "JAWABAN ANDA BENAR, SKOR ANDA BERTAMBAH 10"
TOTALSKOR = TOTALSKOR + 10
Else
Label5 = "JAWABAN SALAH, SKOR ANDA BERKURANG 5"
TOTALSKOR = TOTALSKOR - 5
End If
TULISANSKOR = Str(TOTALSKOR)
Label7.Caption = TULISANSKOR
Command1.Enabled = False
Command2.Enabled = True
Command2.SetFocus
End Sub

Private Sub Command2_Click()                      
Label1.Caption = Int(Rnd * 100)
Label3.Caption = Int(Rnd * 100)                                                        
Text1.Text = ""
Command2.Enabled = False
Command1.Enabled = True
Text1.SetFocus
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Command4_Click()
Form2.Show
Form6.Hide
End Sub
Private Sub Form_Load()
Label1.Caption = Int(Rnd * 100)
Label3.Caption = Int(Rnd * 100)
TOTALSKOR = 0
End Sub
Private Sub FORM_ACTIVATE()
Text1.SetFocus
Command1.Enabled = False
Label7 = "0"
End Sub



7. PROGRAM TARIF TELP FLAT

Dim AWAL, AKHIR, LAMA As Variant

Private Sub Command1_Click()
If Command1.Caption = "START" Then
AWAL = Now
MULAI.Text = Format(AWAL, "HH:MM:SS")
Command1.Caption = "STOP"
ElseIf Command1.Caption = "STOP" Then
AKHIR = Now
LAMA = AWAL - AKHIR
SELESAI.Text = Format(AKHIR, "HH:MM:SS")
LAMA = (Hour(LAMA) * 3600) + (Minute(LAMA) * 60) + (Second(LAMA))
DURASI.Text = LAMA & DETIK
BIAYA = LAMA * 10
BIAYA = " Rp " & BIAYA
Command1.Caption = "START"
ElseIf Command1.Caption = START Then
End If
End Sub

Private Sub Command2_Click()
MULAI.Text = ""
SELESAI.Text = ""
DURASI.Text = ""
BIAYA.Text = ""
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Command4_Click()
Form2.Show
Form7.Hide
End Sub

Private Sub Timer1_Timer()
If Command1.Caption = "STOP" Then
SELESAI.Text = Format(Now, "HH:MM:SS")
DURASI.Text = Format(Now - AWAL, "HH:MM:SS")
End If
End Sub



8. PROGRAM PENJUALAN

Dim HARGA, TOTAL As Single
Private Sub Combo1_Click()
HARGA = Combo1.ItemData(Combo1.ListIndex)
HARGABRG = Format(HARGA, "Rp ###,###")
JUMLAHBRG = ""
TOTALHRG = 0
JUMLAHBRG.SetFocus
End Sub

Private Sub Command1_Click()
Combo1 = ""
HARGABRG = ""
JUMLAHBRG = ""
TOTALHRG = ""
End Sub

Private Sub Command2_Click()
Form2.Show
Form8.Hide
End Sub

Private Sub Form_Load()
Combo1.List(0) = "PENCIL"
Combo1.List(1) = "BUKU"
Combo1.List(2) = "PULPEN"
Combo1.ItemData(0) = 2000
Combo1.ItemData(1) = 3000
Combo1.ItemData(2) = 5000
Combo1.Text = "PILIH"
End Sub

Private Sub JUMLAHBRG_Change()
TOTAL = HARGA * Val(JUMLAHBRG)
TOTALHRG = Format(TOTAL, "Rp ###,###")
End Sub






9. PROGRAM NILAI_MHS

Private Sub Command1_Click()
Select Case NIM
Case 10701: NAMA.Text = "ZAENAL"
Case 20702: NAMA.Text = "SURANA"
Case 10702: NAMA.Text = "EKO"
Case 20703: NAMA.Text = "HERY"
Case 30701: NAMA.Text = "JOKO"
Case Else: NAMA.Text = "TIDAK TERDAFTAR"
End Select
NIM2 = Left(NIM, 1)
If NIM2 = "1" Then
JURUSAN = "MI"
ElseIf NIM2 = "2" Then
JURUSAN = "KA"
ElseIf NIM2 = "3" Then
JURUSAN = "SE"
Else
JURUSAN = "TIDAK TERDAFTAR"
End If
NILAI2 = Val(NILAI)
If NILAI2 > 59 Then
KET = "LULUS"
Else
KET = "TIDAK LULUS"
End If
If NILAI21 > 85 Then
HURUF = "A"
ElseIf NILAI2 > 75 Then
HURUF = "B"
ElseIf NILAI2 > 59 Then
HURUF = "C"
ElseIf NILAI2 > 45 Then
HURUF = "D"
Else
HURUF = "E"
End If
End Sub

Private Sub Command2_Click()
NIM.Text = ""
NILAI.Text = ""
NAMA.Text = ""
JURUSAN.Text = ""
KET.Text = ""
HURUF.Text = ""
End Sub

Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Form2.Show
Form9.Hide
End Sub
























































TARIF TELEPHONE FLAT VB


NAMA        : SURANA. (MI)
                       


TUGAS VISUAL BASIS PROGRAM TARIF TELEPHONE FLAT (LISTEN)


Dim AWAL, AKHIR, LAMA As Variant

Private Sub Command1_Click()
If Command1.Caption = "START" Then
AWAL = Now
Text1.Text = Format(AWAL, "HH:MM:SS")
Command1.Caption = "STOP"
ElseIf Command1.Caption = "STOP" Then
AKHIR = Now
LAMA = AWAL - AKHIR
Text2.Text = Format(AKHIR, "HH:MM:SS")
LAMA = (Hour(LAMA) * 3600) + (Minute(LAMA) * 60) + (Second(LAMA))
Text3.Text = LAMA & " DETIK "
Text4.Text = LAMA * 10
Text4.Text = " Rp " & Text4
Command1.Caption = "START"
ElseIf Command1.Caption = "START" Then
End If
End Sub

Private Sub Command2_Click()
Command2.Caption = "SELESAI"
Unload Me
End Sub

Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub

Private Sub Timer1_Timer()
If Command1.Caption = "STOP" Then
Text2.Text = Format(Now, "HH:MM:SS")
Text3.Text = Format(Now - MULAI, "HH:MM:SS")
End If
End Sub
Selamat Mencoba.