Contoh Database Kontak Telepon di Visual Basic 6.0 (Part 2)
Private Sub CmdTambah_Click()
If TxtNama.Text = "" Then
MsgBox "Nama belum di isi!", vbCritical, "Peringatan!"
ElseIf TxtAlamat.Text = "" Then
MsgBox "Alamat belum di isi!", vbCritical, "Peringatan!"
ElseIf TxtNo.Text = "" Then
MsgBox "Nomor Telepon belum di isi!", vbCritical, "Peringatan!"
ElseIf MsgBox("Apakah anda ingin menambahkan kontak?", vbYesNo, "") = vbYes Then
FormUtama.Adodc1.Recordset.AddNew
FormUtama.Adodc1.Recordset!Nama = TxtNama.Text
FormUtama.Adodc1.Recordset!Alamat = TxtAlamat.Text
FormUtama.Adodc1.Recordset!NoTelp = TxtNo.Text
MsgBox "Kontak Berhasil di Simpan", vbInformation, "Kontak Tertambah"
Bersih
Else
End If
End Sub
Private Sub CmdKembali_Click()
Unload Me
End Sub
Sub Bersih()
TxtNama.Text = ""
TxtAlamat.Text = ""
TxtNo.Text = ""
End Sub
Private Sub CmdKembali_Click()
Unload Me
End Sub
Private Sub CmdSimpan_Click()
If TxtNama.Text = "" Then
MsgBox "Nama belum di isi!", vbCritical, "Peringatan!"
ElseIf TxtAlamat.Text = "" Then
MsgBox "Alamat belum di isi!", vbCritical, "Peringatan!"
ElseIf TxtNo.Text = "" Then
MsgBox "Nomor Telepon belum di isi!", vbCritical, "Peringatan!"
ElseIf MsgBox("Apakah anda ingin mengubah kontak?", vbYesNo, "") = vbYes Then
FormUtama.Adodc1.Recordset!Nama = TxtNama.Text
FormUtama.Adodc1.Recordset!Alamat = TxtAlamat.Text
FormUtama.Adodc1.Recordset!NoTelp = TxtNo.Text
MsgBox "Kontak berhasil diubah", vbInformation, "Kontak Tersimpan"
Else
End If
End Sub
Private Sub Form_Load()
TxtNama.Text = FormUtama.Adodc1.Recordset!Nama
TxtAlamat.Text = FormUtama.Adodc1.Recordset!Alamat
TxtNo.Text = FormUtama.Adodc1.Recordset!NoTelp
End Sub
Link Download :
- Database
- Program VB (RAR lengkap)
By Ahmad Nizar
Thanks to Ibu Ito Riris Immasari,S.Kom
Komentar
Posting Komentar