Baca Juga
Form NewPassword
Sekarang diteruskan untuk mengisi jendela coding
Langkah selanjutnya membuat Form EditPassword
Biar nyambung baca dulu artikel saya sebelumnya untuk membuat Form Menu nya
Sekarang kita membuat Form New Password, Tambahkan sebuah Form (Namai dengan : FrmNewPassword), tambahkan beberapa component sebagai berikut :
- 2 buah CommandButton
- 2 buah TextBox
- dan beberapa buah Label
Susun sedemikian rupa hingga tampilannya akan nampak seperti ini :
- command1, name : Command1, caption : Create Password, enabled = false
- command2, name : Command2, caption : Cancel
- Text1, name : Text1, Text : , PasswordChar : *
- Text2, name : Text2, Text : , PasswordChar : *
- Label1, name : Label1, caption : Enter a Password
- Label2, name : Label2, caption : Type Password Again
Form New Password
Sekarang diteruskan untuk mengisi jendela coding
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Then Exit Sub
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile FrmMenu.Text1.Text, FrmMenu.Text2.Text
Call newPassword(FrmMenu.Text2.Text, Text1.Text)
MsgBox "Password has been created!", vbInformation, ".: Password created success"
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Text1_LostFocus()
Text2.Text = ""
End Sub
Private Sub Text2_Change()
On Error Resume Next
Command1.Enabled = False
If Not Text2.Text = "" Then
If Text2.Text = Text1.Text Then Command1.Enabled = True
Else
Command1.Enabled = False
End If
End Sub
Sub newPassword(dbf As String, NewPwd As String)
On Error GoTo 1
Dim db As Database
Set db = OpenDatabase(dbf, True)
db.newPassword "", NewPwd
db.Close
Exit Sub
1:
If Not Err.Number = 0 Then
MsgBox Err.Description, vbInformation, ".: New Password Created failed"
Exit Sub
End If
End Sub
If Text1.Text = "" Or Text2.Text = "" Then Exit Sub
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile FrmMenu.Text1.Text, FrmMenu.Text2.Text
Call newPassword(FrmMenu.Text2.Text, Text1.Text)
MsgBox "Password has been created!", vbInformation, ".: Password created success"
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Text1_LostFocus()
Text2.Text = ""
End Sub
Private Sub Text2_Change()
On Error Resume Next
Command1.Enabled = False
If Not Text2.Text = "" Then
If Text2.Text = Text1.Text Then Command1.Enabled = True
Else
Command1.Enabled = False
End If
End Sub
Sub newPassword(dbf As String, NewPwd As String)
On Error GoTo 1
Dim db As Database
Set db = OpenDatabase(dbf, True)
db.newPassword "", NewPwd
db.Close
Exit Sub
1:
If Not Err.Number = 0 Then
MsgBox Err.Description, vbInformation, ".: New Password Created failed"
Exit Sub
End If
End Sub
NOTE :
Aplikasi ini dirancang untuk mem-password, dengan terlebih dahulu mengcopy database asli ke path yang lain, untuk menghindari hal-hal yang tidak diinginkan.
Langkah selanjutnya membuat Form EditPassword