Anda di halaman 1dari 13

Laporan Pemrograman Visual I

D
I
S
U
S
U
N

OLEH:



Nama : DESMON KRISTANTO SIAHAAN
Nim : 212510056
Jurusan : TEKNIK INFORMATIKA










FAKULTAS ILMU KOMPUTER
UNIVERSITAS METHODIST INDONESIA
MEDAN


Tampilan Muka Visual Baisc (IDE)/Pengenanalan Visual Basic






























Program Kalkulator





Private Sub CmdClose_Click()
psn = MsgBox("Apakah Anda Ingin Keluar ???", vbYesNo +
vbOKOnly, "Konfirmasi")
If psn = vbYes Then
MsgBox "Terima Kasih"
End
Else
If psn = vbNo Then
MsgBox "Loh Kog enggak jadi", vbOKOnly, "Information"
End If
End If
End Sub
Private Sub CmdFrmGanjilGenap_Click()
Unload Me
FrmNegatifPositif.Show
End Sub

Private Sub HscBil1_Change()
TxtBil1.Text = HscBil1.Value
End Sub

Private Sub HscBil2_Change()
TxtBil2.Text = HscBil2.Value
End Sub
Private Sub OptBagi_Click()
TxtHasil.Text = "Hasilnya adalah: " & Val(TxtBil1.Text) /
Val(TxtBil2.Text)
End Sub

Private Sub OptKali_Click()
TxtHasil.Text = "Hasilnya adalah: " & Val(TxtBil1.Text) *
Val(TxtBil2.Text)
End Sub

Private Sub OptKurang_Click()
TxtHasil.Text = "Hasilnya adalah: " & Val(TxtBil1.Text) -
Val(TxtBil2.Text)
End Sub

Private Sub OptModulus_Click()
TxtHasil.Text = "Hasilnya adalah: " & Val(TxtBil1.Text) Mod
Val(TxtBil2.Text)
End Sub

Private Sub OptTambah_Click()
TxtHasil.Text = "Hasilnya adalah: " & Val(TxtBil1.Text) +
Val(TxtBil2.Text)
End Sub

Program Bilangan Negatif Positif


Private Sub CmdClose_Click()
psn = MsgBox("Apakah Anda Ingin Keluar ???", vbYesNo +
vbOKOnly, "Konfirmasi")
If psn = vbYes Then
MsgBox "Terima Kasih !!!"
End
Else
If psn = vbNo Then
MsgBox "Loh Kog Enggak Jadi ..!!", vbInformation,
"Information"
End If
End If
End Sub

Private Sub CmdFrmKalkulator_Click()
Unload Me
FrmAritmatika.Show
End Sub




Private Sub CmdUlang_Click()
TxtBilangan.Text = ""
TxtHasil.Text = ""
TxtBilangan.SetFocus
End Sub

Private Sub Form_Activate()
TxtBilangan.SetFocus
End Sub

Private Sub CmdUji_Click()
If TxtBilangan.Text = Empty Then
MsgBox "Bilangan Harus Diisi", vbExclamation, "Pengingat"
TxtBilangan.SetFocus
ElseIf Val(TxtBilangan.Text) >= 0 Then
TxtHasil.Text = TxtBilangan.Text & " Adalah Bilangan Positif"
Else
TxtHasil.Text = TxtBilangan.Text & " Adalah Bilangan Negatif"
End If
End Sub

Program Mencari Luas Bangun Datar & Ruang






Private Sub Timer1_Timer()
LblWaktu.Item(0).Caption = "Jam : " & Time & " Tanggal :" &
Date
LblWaktu.Item(1).Caption = "Jam : " & Time & " Tanggal :" &
Date
LblWaktu.Item(2).Caption = "Jam : " & Time & " Tanggal :" &
Date
End Sub

Private Sub Form_Activate()
NonAktifLayang
NonAktifLingkaran
NonAktifSegitiga
End Sub

Private Sub CmdUlangLayang_Click()
BersihLayang
End Sub
Private Sub CmdKeluarLayang_Click()
KeluarLayang
End Sub

Private Sub NonAktifLayang()
TxtDiagonal2.Enabled = False
TxtLLayang.Enabled = False
CmdUlangLayang.Enabled = False
CmdKeluarLayang.Enabled = False
TxtDiagonal1.SetFocus
End Sub

Private Sub BersihLayang()
TxtDiagonal1.Text = ""
TxtDiagonal2.Text = ""
TxtLLayang.Text = ""
TxtDiagonal1.SetFocus
TxtDiagonal2.Enabled = False
TxtLLayang.Enabled = False
CmdUlangLayang.Enabled = False
CmdKeluarLayang.Enabled = False
End Sub

Private Sub TxtDiagonal1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtDiagonal2.Enabled = True
TxtDiagonal2.SetFocus
End If
End Sub

Private Sub TxtDiagonal2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtLLayang.Enabled = True
TxtLLayang.Text = "Luas = " & " " & ((TxtDiagonal1.Text *
TxtDiagonal2.Text) / 2) & " " & "cm2"
CmdUlangLayang.Enabled = True
CmdKeluarLayang.Enabled = True
CmdUlangLayang.SetFocus
End If
End Sub
Private Sub KeluarLayang()
Pesan = MsgBox("Exit Form Luas Bangun Datar & Ruang ",
vbQuestion + vbYesNo, "Konfirmasi")
If Pesan = vbYes Then
MsgBox "Terima Kasih", vbInformation, "Informasi"
End
Else
If Pesan = vbNo Then
MsgBox "Loh Kog Enggak Jadi!!!", vbOKOnly, "Informasi"
BersihLayang
End If
End If
End Sub

Private Sub NonAktifLingkaran()
TxtLLingkaran.Enabled = False
CmdUlangLingkaran.Enabled = False
CmdKeluarLingkaran.Enabled = False
TxtJariJari.SetFocus
End Sub

Private Sub TxtJariJari_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtLLingkaran.Enabled = True
TxtLLingkaran.Text = "Luas =" & " " & 3.14 * TxtJariJari *
TxtJariJari & " " & "cm2"
CmdUlangLingkaran.Enabled = True
CmdKeluarLingkaran.Enabled = True
CmdUlangLingkaran.SetFocus
End If
End Sub

Private Sub CmdUlangLingkaran_Click()
BersihLingkaran
End Sub

Private Sub BersihLingkaran()
TxtJariJari.Text = ""
TxtLLingkaran.Text = ""
CmdUlangLingkaran.Enabled = False
CmdKeluarLingkaran.Enabled = False
TxtJariJari.SetFocus
End Sub

Private Sub KeluarLingkaran()
Pesan = MsgBox("Exit Form Luas Bangun Datar & Ruang ",
vbQuestion + vbYesNo, "Konfirmasi")
If Pesan = vbYes Then
MsgBox "Terima Kasih", vbInformation, "Informasi"
End
Else
If Pesan = vbNo Then
MsgBox "Loh Kog Enggak Jadi!!!", vbOKOnly + 32,
"Informasi"
BersihLingkaran
End If
End If End Sub
Private Sub CmdKeluarLingkaran_Click()
KeluarLingkaran
End Sub

Private Sub NonAktifSegitiga()
TxtTinggi.Enabled = False
TxtLSegitiga.Enabled = False
CmdUlangSegitiga.Enabled = False
CmdKeluarSegitiga.Enabled = False
TxtAlas.SetFocus
End Sub

Private Sub TxtAlas_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtTinggi.Enabled = True
TxtTinggi.SetFocus
End If
End Sub

Private Sub TxtTinggi_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtLSegitiga.Enabled = True
TxtLSegitiga.Text = "Luas =" & " " & ((TxtAlas.Text *
TxtTinggi.Text) / 2) & " " & "cm2"
CmdUlangSegitiga.Enabled = True
CmdKeluarSegitiga.Enabled = True
CmdUlangSegitiga.SetFocus
End If
End Sub


Private Sub BersihSegitiga()
TxtAlas.Text = ""
TxtTinggi.Text = ""
TxtLSegitiga.Text = ""
CmdUlangSegitiga.Enabled = False
CmdKeluarSegitiga.Enabled = False
TxtAlas.SetFocus
End Sub

Private Sub CmdUlangSegitiga_Click()
BersihSegitiga
End Sub
Private Sub KeluarSegitiga()
Pesan = MsgBox("Exit Form Luas Bangun Datar & Ruang ",
vbQuestion + vbYesNo, "Konfirmasi")
If Pesan = vbYes Then
MsgBox "Terima Kasih", vbInformation, "Informasi"
End
Else
If Pesan = vbNo Then
MsgBox "Loh Kog Enggak Jadi!!!", vbOKOnly + 32,
"Informasi"
BersihSegitiga
End If
End If
End Sub

Private Sub CmdKeluarSegitiga_Click()
KeluarSegitiga
End Sub

Program Mencari Nilai Huruf



Private Sub CmdBatal_Click()
TxtAngka.Text = Empty
TxtHuruf.Text = Empty
CmdProses.Enabled = False
CmdBatal.Enabled = False
CmdKeluar.Enabled = True
TxtAngka.SetFocus
End Sub

Private Sub CmdKeluar_Click()
Pesan = MsgBox("Exit Program ???", vbQuestion + vbYesNo,
"Konfirmasi")
If Pesan = vbYes Then
MsgBox "Terima Kasih", vbOKOnly, "Konfirmasi"
End
Else
If Pesan = vbNo Then
MsgBox "Loh Kog Enggak Jadi", vbOKOnly, "Konfirmasi"
End If
End If
End Sub

Private Sub CmdProses_Click()
Dim Angka As Integer
Dim Huruf As String
Angka = TxtAngka.Text

If (Angka >= 70) Then
Huruf = "LULUS"
Else
Huruf = "TIDAK LULUS"
End If
TxtHuruf.Text = Huruf
CmdBatal.SetFocus
End Sub

Private Sub Form_Activate()
TxtHuruf.Enabled = False
CmdProses.Enabled = False
CmdBatal.Enabled = False
CmdKeluar.Enabled = False
TxtAngka.SetFocus
End Sub
Private Sub TxtAngka_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtHuruf.Enabled = True
CmdProses.Enabled = True
CmdBatal.Enabled = True
CmdProses.SetFocus
End If
End Sub



Program Kasir







Private Sub CboBanyak_Click()
If CboBanyak.Text = "01" Then
TxtTotal.Text = CboBanyak.Text * TxtHarga.Text
ElseIf CboBanyak.Text = "02" Then
TxtTotal.Text = CboBanyak.Text * TxtHarga.Text
ElseIf CboBanyak.Text = "03" Then
TxtTotal.Text = CboBanyak.Text * TxtHarga.Text
ElseIf CboBanyak.Text = "04" Then
TxtTotal.Text = CboBanyak.Text * TxtHarga.Text
Else
TxtTotal.Text = CboBanyak.Text * TxtHarga.Text
End If
TxtTotal.Enabled = 1
TxtBayar.Enabled = 1
TxtBayar.SetFocus
End Sub

Private Sub CboKdBarang_Click()
If CboKdBarang.Text = "KDOO1" Then
TxtNmBarang.Text = "Flash Disk"
TxtHarga.Text = "50000"
ElseIf CboKdBarang.Text = "KD002" Then
TxtNmBarang.Text = "Mouse"
TxtHarga.Text = "65000"
ElseIf CboKdBarang.Text = "KD003" Then
TxtNmBarang.Text = "Memory"
TxtHarga.Text = "250000"
ElseIf CboKdBarang.Text = "KD004" Then
TxtNmBarang.Text = "Harddisk"
TxtHarga.Text = "500000"
Else
TxtNmBarang.Text = "Keyboard"
TxtHarga.Text = "125000"
End If
CboBanyak.Enabled = 1
CboBanyak.SetFocus
End Sub

Private Sub CmdBatal_Click()
Batal
End Sub
Private Sub Batal()
CboKdBarang.Text = ""
CboKdBarang.SetFocus
TxtNmBarang.Text = ""
TxtHarga.Text = ""
CboBanyak.Text = ""
TxtTotal.Text = ""
TxtBayar.Text = ""
TxtKembali.Text = ""
NonAktif
End Sub

Private Sub CmdKeluar_Click()
pesan = MsgBox("Exit Program Kasir??", vbQuestion + vbYesNo,
"Konfirmasi")
If pesan = vbYes Then
MsgBox "Terima Kasih", vbOKOnly, "Konfirmasi"
End
Else
If pesan = vbNo Then
MsgBox "Loh Kog Enggak jadi", vbInformation, "Informasi"
End If
Batal
End If
End Sub

Private Sub Form_Activate()
NonAktif
End Sub
Private Sub NonAktif()
CboBanyak.Enabled = 0
TxtTotal.Enabled = 0
TxtBayar.Enabled = 0
TxtKembali.Enabled = 0
CmdBatal.Enabled = 0
CboKdBarang.SetFocus
End Sub

Private Sub TxtBayar_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtKembali.Text = TxtTotal.Text - TxtBayar.Text
TxtKembali.Enabled = 1
CmdBatal.Enabled = 1
CmdBatal.SetFocus
End If
End Sub






Program Mencari Nilai Pangkat Bilangan





Private Sub CmdHapus_Click()
TxtNilai = Empty
TxtPangkat = Empty
TxtHasil = Empty
End Sub

Private Sub CmdProses_Click()
Dim a As Integer
Dim b As Integer
Dim Jlh As Integer
a = Val(TxtNilai)
b = Val(TxtPangkat)
Jlh = 1
For i = 1 To b
Jlh = Jlh * a
Next i
TxtHasil.Text = Jlh
End Sub

Private Sub CmdTutup_Click()
psn = MsgBox("Exit Program ???", 32 + 4, "Konfirmasi")
If psn = vbYes Then
MsgBox "Terima Kasih Atas Kunjungan Anda", vbInformation,
"informasi"
End
If psn = vbNo Then
MsgBox "Loh Kok Enggak Jadi Yachhhh", vbCritical, "Pesan"
End If
End If
End Sub

Private Sub TxtNilai_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtPangkat.SetFocus
End If
End Sub
Private Sub TxtPangkat_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
CmdProses.SetFocus
End If
End Sub

Program Faktorial




Private Sub cmdHapus_Click()
TxtFaktorial = ""
TxtHasil = ""
End Sub

Private Sub cmdTutup_Click()
End
End Sub


Private Sub TxtFaktorial_KeyPress(KeyAscii As Integer)
Dim a As Long
Dim Jlh As Long
Dim Hasil As Long
a = Val(TxtFaktorial.Text)
Jlh = 1
If KeyAscii = 13 Then

If a <= 0 Then
TxtHasil.Text = 0
Else
For i = a To 1 Step -1
Jlh = Jlh * i
Next i
End If
TxtHasil.Text = Jlh
End If
End Sub




















Program Penggajian









Private Sub NonAktif()
txtNama.Enabled = 0
cboGol.Enabled = 0
optLaki.Enabled = 0
optPerempuan.Enabled = 0
cboStatus.Enabled = 0
txtTunjangan.Enabled = 0
txtGapok.Enabled = 0
txtGaber.Enabled = 0
cmdHitung.Enabled = 0
cmdUlang.Enabled = 0
End Sub
Private Sub Form_Load()
For i = 212510054 To 212510056
CboNIP.AddItem i
Next i

NonAktif
End Sub
Private Sub CboNIP_Click()
If CboNIP.Text = "212510054" Then
txtNama.Text = "Evan Sembiring"
ElseIf CboNIP.Text = "212510055" Then
txtNama.Text = "Ramot Manurung"
Else
txtNama.Text = "Desmon Siahaan"
End If

txtNama.Enabled = 1
cboGol.Enabled = 1
cboGol.SetFocus
End Sub
Private Sub cboGol_Click()
If cboGol.Text = "III A" Then
txtGapok.Text = 1500000
txtGapok = Format(txtGapok, "###,###,###")
ElseIf cboGol.Text = "III B" Then
txtGapok.Text = 2000000
txtGapok = Format(txtGapok, "###,###,###")
ElseIf cboGol.Text = "III C" Then
txtGapok.Text = 2500000
txtGapok = Format(txtGapok, "###,###,###")
Else
txtGapok.Text = 3000000
txtGapok = Format(txtGapok, "###,###,###")
End If

optLaki.Enabled = 1
optPerempuan.Enabled = 1
txtGapok.Enabled = 1
End Sub
Private Sub optLaki_Click()
cboStatus.Enabled = 1
cboStatus.SetFocus
End Sub
Private Sub optPerempuan_Click()
cboStatus.Enabled = 1
cboStatus.SetFocus
End Sub

Private Sub cboStatus_Click()
If cboStatus.Text = "Menikah" Then
txtTunjangan = 750000
txtTunjangan = Format(txtTunjangan, "###,###,###")
Else
txtTunjangan = 2000000
txtTunjangan = Format(txtTunjangan, "###,###,###")
End If

txtTunjangan.Enabled = 1
cmdHitung.Enabled = 1
txtGaber.Enabled = 1
cmdHitung.SetFocus
End Sub
Private Sub cmdHitung_Click()
Dim a, b As Long
a = txtTunjangan
b = txtGapok
c = Format(a + b, "###,###,###")
txtGaber = c

cmdUlang.Enabled = 1
cmdUlang.SetFocus
cmdHitung.Enabled = 0
End Sub
Private Sub Ulang()
CboNIP = Empty
txtNama = Empty
cboGol = Empty
optLaki = Empty
optPerempuan = Empty
cboStatus = Empty
txtTunjangan = Empty
txtGapok = Empty
txtGaber = Empty
End Sub
Private Sub cmdUlang_Click()
Ulang
cmdUlang.Enabled = 0
CboNIP.SetFocus

NonAktif
End Sub
Private Sub cmdKeluar_Click()
pesan = MsgBox("Exit Program??", vbQuestion + vbYesNo,
"Informasi")
If pesan = vbYes Then
MsgBox "Terima Kasih", vbInformation
End
If pesan = vbNo Then
MsgBox "Loh Kog Enggak Jadi", vbInformation
End If
End If
Ulang
End Sub

Program Tiket (Kuis)






Private Sub cboJlh_Click()
txtTotal = Val(txtHarga.Text) * cboJlh.Text
txtTotal = Format(txtTotal, "Rp ###,###,###")
End Sub

Private Sub cboTujuan_Click()
If cboTujuan.Text = "Medan Sidikalang" Then
txtHarga.Text = 70000
ElseIf cboTujuan.Text = "Medan Sibolga" Then
txtHarga = 80000
ElseIf cboTujuan.Text = "Medan Siantar" Then
txtHarga = 60000
ElseIf cboTujuan.Text = "Sidikalang Medan" Then
txtHarga = 70000
ElseIf cboTujuan.Text = "Sibolga Medan" Then
txtHarga = 80000
Else
txtHarga = 60000
End If
End Sub

Private Sub cmdBatal_Click()
cboTujuan.Text = ""
cboMobil.Text = ""

cboWaktu.Text = ""
txtHarga.Text = ""
cboJlh.Text = ""
txtTotal.Text = ""
txtBayar.Text = ""
txtKembali.Text = ""
txtPembeli.Text = ""
End Sub



Private Sub Form_Activate()
txtPembeli.SetFocus
For i = 1 To 10
cboJlh.AddItem i
Next i
End Sub

Private Sub txtBayar_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtBayar = Format(txtBayar, "Rp ###,###,###") & ",-"
If txtBayar = txtTotal Then
txtKembali = "Uang nya pas, Terima kasih :)"
Else
If txtBayar = "" Or txtBayar < txtTotal Then
txtKembali = "Kurang" & Space(1) & Format(txtBayar -
txtTotal, "Rp ###,###,###") & ",-"
Else
txtKembali = "Kembali" & txtBayar - txtTotal

End If
End If
End If
End Sub

Program Tebak Angka







Private Sub cmdStart_Click()
Timer1.Enabled = True

lblHasil.Caption = ""
lblMenangkalah.Caption = ""
End Sub

Private Sub cmdStop_Click()
lblHasil.Caption = "Angka yang muncul : " & L1.Caption &
L2.Caption & L3.Caption & L4.Caption

Timer1.Enabled = False
If li = L2 Or L1 = L3 Or L1 = L4 Or L2 = L3 Or L2 = L4 Or L3 =
L4 Then
lblMenangkalah.Caption = "Anda Menang bro"
Else
lblMenangkalah.Caption = "Tidak ada angka yang sama You
kalah broo "
End If
End Sub

Private Sub Form_Load()
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
Randomize
L1.Caption = Int(Rnd() * 10)
L2.Caption = Int(Rnd() * 10)
L3.Caption = Int(Rnd() * 10)
L4.Caption = Int(Rnd() * 10)

'lblMenangkalah.Visible = Not lblMenangkalah.Visible
End Sub

Program Teks Berjalan dan Teks Berkedip





Dim i, x As String

Private Sub Judul_Timer()
Dim Jdl As String
i = i + 1

Jdl = "Latihan dengan timer kontrol"
If i > Len(Jdl) Then i = 0
Me.Caption = Left(Jdl, Len(Jdl) - (Len(Jdl) - i))
End Sub

Private Sub Timer1_Timer()
Dim Teks As String
Teks = "Pemrograman Visual Basic dengan timer"
lblTeks.Caption = Teks
lblTeks.Visible = Not lblTeks.Visible
End Sub

Program Rumah Makan








Private Sub cmdPesan_Click()
Pilihan = ""
For i = 0 To 27
x = Check1(i).Value = 1
If Check1(i).Value = 1 Then
x = Val(LblHarga(i).Caption)
Pilihan = Pilihan + Check1(i).Caption + " "
y = Val(y) + x
End If
Next i
LblPesan.Caption = Pilihan
txtTotal.Text = y
txtTotal = Format(txtTotal, "Rp ###,###,###") & ",-"
txtBayar.SetFocus
End Sub


Private Sub txtBayar_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtBayar = Format(txtBayar, "Rp ###,###,###") & ",-"
If txtBayar = txtTotal Then
LblKet = "Uang nya pas, Terima Kasih :)"
Else
If txtBayar = "" Or txtBayar < txtTotal Then
LblKet = "Kurang" & Format(txtTotal - txtBayar, "Rp
###,###,###") & ",-"
Else
LblKet = "Kembali" & Format(txtBayar - txtTotal, "Rp
###,###,###") & ",-"
End If
CmdPesanBaru.SetFocus
End If
End If
End Sub

Private Sub PesananBaru()
LblPesan.Caption = Empty
txtTotal.Text = Empty
txtBayar.Text = Empty
LblKet.Caption = Empty
For i = 0 To 27
Check1(i).Value = 0
Next i
End Sub
Private Sub CmdPesanBaru_Click()
PesananBaru
End Sub

Private Sub cmdKeluar_Click()
pesan = MsgBox("Exit Aplication??", vbQuestion + vbYesNo,
"Konfirmasi")
If pesan = vbYes Then
MsgBox "Terima Kasih Atas Kunjungan Anda," & vbCrLf &
"Aplikasi Segera Ditutup", vbExclamation, "Pesan"
End
Else
If pesan = vbNo Then
MsgBox "Loh,Kog Enggak Jadi Yachhh", vbInformation, ""
End If
PesananBaru
End If
End Sub

MDI Form

Private Sub mnuExit_Click()
psn = MsgBox("Exit Application???", vbYesNo, "Konfirmasi")
If psn = vbYes Then
End
End If
End Sub

Private Sub mnuKasir_Click()
FrmKasir.Show
End Sub

Private Sub mnuMataUang_Click()
frmMataUang.Show
End Sub

Private Sub mnuSegitiga_Click()
frmSegitiga.Show
End Sub

Private Sub mnuTebakAngka_Click()
frmTebakAngka.Show
End Sub

Private Sub mnuTeksUlang_Click()
frmPerulangan.Show
End Sub

Private Sub Timer1_Timer()
Me.StatusBar1.Panels(1) = Format(Now, "hh:mm:ss")
Me.StatusBar1.Panels(2) = Format(Now, "dd-mm-yyyy")
Me.StatusBar1.Panels(3) = "Desmon Kristanto Siahaan"
End Sub

Program Database Mahasiswa







Public conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public koneksi As String


Private Sub cmdHapus_Click()
hapus = MsgBox("Yakin Menghapus Data", vbYesNo, "Hapus
Data")
If hapus = vbYes Then
rs.Delete
End If
End Sub

Private Sub cmdSimpan_Click()
rs.Find "NPM='" & txtNPM.Text & "'", adSearchForward,
adBookmarkFirst
If rs.EOF Then
rs.AddNew
rs!NPM = txtNPM.Text
rs!Nama = txtNama.Text
rs!Fakultas = cboFakultas.Text
rs!Jurusan = cboJurusan.Text
rs!Telp = txtTelp.Text
rs!Alamat = txtAlamat.Text
rs.Update
Else
MsgBox "Maaf,NPM Sudah Tersimpan", vbCritical
End If

txtNPM = ""
txtNama = ""
cboFakultas = ""
cboJurusan = ""
txtTelp = ""
txtAlamat = ""

txtNPM.SetFocus
End Sub

Private Sub Form_Activate()
txtNPM.SetFocus
End Sub

Private Sub Form_Load()
'conn.CursorLocation = adUseClient
koneksi = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\DATA MHS\212510056 Desmon\Visual
Basic\Mahasiswa\mahasiswa.mdb;Persist Security Info=False"
conn.Open koneksi
rs.Open "tblMahasiswa", conn, 1, 3






With cboFakultas
.AddItem "Kedokteran"
.AddItem "Ekonomi"
.AddItem "Sastra"
.AddItem "Pertanian"
.AddItem "Ilmu Komputer"
End With

With cboJurusan
.AddItem "Profersi Dokter"
.AddItem "Manajemen"
.AddItem "Sastra Inggris"
.AddItem "Agroteknologi"
.AddItem "Teknik Informatika"
End With
End Sub