Membuat Form Ganti Password [VB 6.0]

Jika sebelumnya kita sudah Belajar bagaimana cara membuat Form Login dan Form User maka sekarang saatnya kita belajar untuk bab berikutnya yaitu Cara membuat Form Ganti Password User pada VB. untuk membuat Form ini pastikan anda sudah membuat  Database User / Admin. Jika belum anda bisa mengikuti cara membuatnya disini

Nah sekarang anda bisa membuat Form seperti gambar diatas. dan Codingnya seperti dibawah ini :

Private Sub Command1_Click()
If Text4 <> Text3 Then
        MsgBox "password konfirmasi tidak sama"
        Text4.SetFocus
        Text4 = ""
    Else
        Pesan = MsgBox("yakin password akan diganti", vbYesNo)
        If Pesan = vbYes Then
            Dim editpwd As String
            editpwd = "update admin set passworduser='" & Text4 & "' where kodeuser='" & Text1 & "' and passworduser='" & Text2 & "'"
            koneksi.Execute editpwd
            Unload Me
        Else
            Unload Me
        End If
    End If
End Sub

Sub Form_Load()
    Call BukaDB
    Text1.MaxLength = 6
    Text2.MaxLength = 15
    Text3.MaxLength = 15
    Text2.PasswordChar = "X"
    Text3.PasswordChar = "X"
    Text4.PasswordChar = "X"
End Sub
Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
    Call BukaDB
    RSuser.Open "select * from admin where kodeuser='" & Text1 & "'", koneksi
    If Not RSuser.EOF Then
        Text2.SetFocus
    Else
        MsgBox "Kode user salah "
        Text1.SetFocus
        Text1 = ""
    End If
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
    Call BukaDB
    RSuser.Open "select * from admin where kodeuser='" & Text1 & "' and passworduser='" & Text2 & "'", koneksi
    If Not RSuser.EOF Then
        Text3.SetFocus
    Else
        MsgBox "password lama salah "
        Text2.SetFocus
        Text2 = ""
    End If
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
    If Text3 = "" Then
        MsgBox "password baru belum dibuat"
        Text3.SetFocus
    Else
        Text4.SetFocus
    End If
End If
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
Command1.SetFocus
End If
End Sub

Gampang bukan? Semoga bermanfaat yagh..
Jika anda belum bisa juga anda bisa langsung download dibawah ini :
DOWNLOAD
Previous
Next Post »
Thanks for your comment