Setelah kita melihat contoh aplikasi jadwal penerimaan siswa gres sekolah mengemudi memakai visual basic 6.0, selanjutnya kita akan menciptakan form ganti password.
Pertama-tama buat terlebih dahulu formnya menyerupai dibawah ini, juga beri name masing-masing :
Catatan :
A. Buat textbox gres dan beri name "password", pada propertiesya ubah visible ke false
B. Tambahkan timer
1. Klik pada tpasslama dan pastekan koding berikut (delarasinya ubah ke KeyPress) :
If KeyAscii = 13 Then
Call koneksi
rsdatauser.Open "select*from tuser where kodeuser='" & kodeuser.Text & "'", KON
If rsdatauser.EOF Then
password.Text = ""
Else
password.Text = rsdatauser.Fields("password")
If tpasslama.Text <> password.Text Then
MsgBox "Password Lama anda Salah", vbCritical
tpasslama.Text = ""
tpasslama.SetFocus
Else
tpassbaru.Enabled = True
tpassbaru.SetFocus
cbbatal.Enabled = True
End If
End If
End If
Call koneksi
rsdatauser.Open "select*from tuser where kodeuser='" & kodeuser.Text & "'", KON
If rsdatauser.EOF Then
password.Text = ""
Else
password.Text = rsdatauser.Fields("password")
If tpasslama.Text <> password.Text Then
MsgBox "Password Lama anda Salah", vbCritical
tpasslama.Text = ""
tpasslama.SetFocus
Else
tpassbaru.Enabled = True
tpassbaru.SetFocus
cbbatal.Enabled = True
End If
End If
End If
3. Klik pada tpassbaru dan pastekan koding berikut (delarasinya ubah ke KeyPress) :
If KeyAscii = 13 Then
tkonpass.Enabled = True
tkonpass.SetFocus
End If
tkonpass.Enabled = True
tkonpass.SetFocus
End If
4. Klik pada tkonpass dan pastekan koding berikut (delarasinya ubah ke KeyPress) :
If KeyAscii = 13 Then
If tkonpass.Text <> tpassbaru.Text Then
MsgBox "Password Baru dan Konfirmasi berbeda", vbCritical, "INFO"
tpassbaru.Text = ""
tkonpass.Text = ""
tpassbaru.SetFocus
Else
cbperbarui.Enabled = True
End If
End If
If tkonpass.Text <> tpassbaru.Text Then
MsgBox "Password Baru dan Konfirmasi berbeda", vbCritical, "INFO"
tpassbaru.Text = ""
tkonpass.Text = ""
tpassbaru.SetFocus
Else
cbperbarui.Enabled = True
End If
End If
5. Klik pada cbperbarui dan pastekan koding berikut (delarasinya ubah ke click):
Call koneksi
rsdatauser.Open "update tuser set password='" & tkonpass & "' where kodeuser='" & kodeuser.Text & "'", KON
MsgBox "Password telah diupdate"
Call bersih
Call nonaktif
rsdatauser.Open "update tuser set password='" & tkonpass & "' where kodeuser='" & kodeuser.Text & "'", KON
MsgBox "Password telah diupdate"
Call bersih
Call nonaktif
6. Klik pada cbbatal dan pastekan koding berikut (delarasinya ubah ke click:
Call bersih
Call nonaktif
Call nonaktif
7. Klik pada bmenu dan pastekan koding berikut (delarasinya ubah ke click):
a = MsgBox("Yakin Untuk Menutup Form Ini Dan kembali ke Menu Utama ?", vbCritical + vbYesNo, "INFO")
If a = vbYes Then
fgantipassword.Hide
If fmenu.StatusBar.Panels(6) = "Admin" Then
Call aktifadmin
Else
Call aktifuser
End If
End If
If a = vbYes Then
fgantipassword.Hide
If fmenu.StatusBar.Panels(6) = "Admin" Then
Call aktifadmin
Else
Call aktifuser
End If
End If
8. Klik pada timer dan pastekan koding berikut :
tjam.Text = Time
tltgl.Text = Format(Date, "yyyy-m-d")
tltgl.Text = Format(Date, "yyyy-m-d")
9. Buat form_load dan pastekan koding berikut :
Me.Left = 100
Me.Top = 0
Call koneksi
Call nonaktif
tpasslama.PasswordChar = "*"
tpassbaru.PasswordChar = "*"
tkonpass.PasswordChar = "*"
password.Visible = False
Me.Width = 12315
Me.Height = 6150
tpassbaru.MaxLength = 5
tkonpass.MaxLength = 5
tpasslama.MaxLength = 5
kodeuser.Text = fmenu.StatusBar.Panels(2)
Me.Top = 0
Call koneksi
Call nonaktif
tpasslama.PasswordChar = "*"
tpassbaru.PasswordChar = "*"
tkonpass.PasswordChar = "*"
password.Visible = False
Me.Width = 12315
Me.Height = 6150
tpassbaru.MaxLength = 5
tkonpass.MaxLength = 5
tpasslama.MaxLength = 5
kodeuser.Text = fmenu.StatusBar.Panels(2)
10. Buat Sub higienis dan pastekan koding berikut :
tpasslama.Text = ""
tpassbaru.Text = ""
tkonpass.Text = ""
tpassbaru.Text = ""
tkonpass.Text = ""
11. Buat Sub aktif dan pastekan koding berikut :
tkodeuser.Enabled = True
tpasslama.Enabled = True
tpassbaru.Enabled = True
tkonpass.Enabled = True
tpasslama.Enabled = True
tpassbaru.Enabled = True
tkonpass.Enabled = True
12. Buat Sub nonaktif dan pastekan koding berikut :
kodeuser.Enabled = False
tpassbaru.Enabled = False
tkonpass.Enabled = False
cbperbarui.Enabled = False
cbbatal.Enabled = False
tpassbaru.Enabled = False
tkonpass.Enabled = False
cbperbarui.Enabled = False
cbbatal.Enabled = False
13. Buat Sub aktifadmin dan pastekan koding berikut :
fmenu.mganti.Enabled = True
fmenu.mdata.Enabled = True
fmenu.mdatauser.Enabled = True
fmenu.mdatabiaya.Enabled = True
fmenu.mdatasiswa.Enabled = False
fmenu.mriwayat.Enabled = True
fmenu.mlogout.Enabled = True
fmenu.mloguser.Enabled = False
fmenu.mmobil.Enabled = True
fmenu.mjam.Enabled = True
fmenu.mlog.Enabled = True
fmenu.mdata.Enabled = True
fmenu.mdatauser.Enabled = True
fmenu.mdatabiaya.Enabled = True
fmenu.mdatasiswa.Enabled = False
fmenu.mriwayat.Enabled = True
fmenu.mlogout.Enabled = True
fmenu.mloguser.Enabled = False
fmenu.mmobil.Enabled = True
fmenu.mjam.Enabled = True
fmenu.mlog.Enabled = True
14. Buat Sub aktifuserdan pastekan koding berikut :
fmenu.mlog.Enabled = True
fmenu.mganti.Enabled = True
fmenu.mdata.Enabled = True
fmenu.mdatabiaya.Enabled = False
fmenu.mdatauser.Enabled = False
fmenu.mdatasiswa.Enabled = True
fmenu.mjadwal.Enabled = True
fmenu.mtransaksi.Enabled = True
fmenu.mlaporan.Enabled = True
fmenu.mlogout.Enabled = True
fmenu.mloguser.Enabled = False
fmenu.mmobil.Enabled = False
fmenu.mjam.Enabled = False
Sumber http://www.hendrisetiawan.comfmenu.mganti.Enabled = True
fmenu.mdata.Enabled = True
fmenu.mdatabiaya.Enabled = False
fmenu.mdatauser.Enabled = False
fmenu.mdatasiswa.Enabled = True
fmenu.mjadwal.Enabled = True
fmenu.mtransaksi.Enabled = True
fmenu.mlaporan.Enabled = True
fmenu.mlogout.Enabled = True
fmenu.mloguser.Enabled = False
fmenu.mmobil.Enabled = False
fmenu.mjam.Enabled = False