Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to Code a change password form in vb6

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 23-06-2012
Member
 
Join Date: May 2012
Posts: 94
How to Code a change password form in vb6
  

I am unable to code a change password form using vb6, have tried many things but nothing is working. I want that the change password form should be accessed by a button on the login form (frmPassword) which is actually a seperate form to the login form (frmChangePassword). But from the login form, the change password form wont be reading the password even though after declaring password variable as the global variable. So can anyone help me out in this situation?

Reply With Quote
  #2  
Old 23-06-2012
Member
 
Join Date: May 2008
Posts: 2,382
Re: How to Code a change password form in vb6

It is very easy to change the old password, all you need to do is rewrite that particular file with the new one. Also tell the user to type the old password so that the right user is changing the password without any conflicts. After that create a new function which will write a password to the txt file and if any new user is using it then just call it and if that user is not using it then simply ask for old password and check if its a correct call for the same function made or not. You have to then use "&" for the code you may use when adding strings together instead of using "+". Check the below code which will show you how the compiler will try to sum up the strings:

Code:
Option Explicit
'user info(password and username)'
Private Type USER_INFO
    UserName As String
    Password As String
End Type
Private UI As USER_INFO

Private Function Write_UsreInfo_In_File() As String
'function that write the user info to a file'
'the function return "SUCCSESS" if the file is writen correct'
'and return the error number and discription in case of error'
On Error GoTo err_h
    'open the file for input'
    Open App.Path & "\Users\" & openfile & ".txt" For For Binary As #2
    'write in the file the whole structure'
    Put #2, , UI
    'close the file'
    Close 2
    'return result'
    Write_UsreInfo_In_File = "SUCCSESS"
    Exit Function
err_h:
    Write_UsreInfo_In_File = Err.Number & "  " & Err.Description
End Function

Private Sub cmdChangePass_Click()
    'check for username if the textbox is empty exit the sub'
    If txtUsername.Text = "" Then
        MsgBox "ENTER USER NAME", vbCritical
        Exit Sub
    End If
    'check password if textbox is empty exit sub'
    If txtPassword.Text = "" Then
        MsgBox "ENTER PASSWORD", vbCritical
        Exit Sub
    End If
    'check for the new password'
    If txtNewPassword.Text = "" Then
        MsgBox "ENTER NEW PASSWORD", vbCritical
        Exit Sub
    End If
    'load the user info'
    Load_User_Info
    'check for the password and username'
    If txtPassword.Text = UI.Password And txtUsername.Text = UI.UserName Then
        'if they are correct add the info to the type'
        UI.Password = txtNewPassword.Text
        UI.UserName = txtUsername.Text
        'save the info to the file'
        MsgBox Write_UsreInfo_In_File
    Else
        'if not a mesage show up'
        MsgBox "INVALID USERNAME OR PASSWORD!!!", vbInformation
    End If
End Sub

Private Sub cmdNewUser_Click()
    'check for username if the textbox is empty exit the sub'
    If txtUsername.Text = "" Then
        MsgBox "ENTER USER NAME", vbCritical
        Exit Sub
    End If
    'check for password if the textbox is empty exit the sub'
    If txtPassword.Text = "" Then
        MsgBox "ENTER PASSWORD", vbCritical
        Exit Sub
    End If
    'input the info for the new user in the type and show the msg from the function'
    UI.Password = Text2.Text
    UI.UserName = Text1.Text
    MsgBox Write_UsreInfo_In_File
End Sub

Private Sub Load_User_Info()
    'the sub load the user info from a file to the type'
    Open App.Path & "\Users\" & openfile & ".txt" For Binary As #2
    Get #2, , UI
    Close 2
End Sub
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #3  
Old 23-06-2012
Member
 
Join Date: May 2009
Posts: 532
Re: How to Code a change password form in vb6

You can use the NewPassword method to change the database password, below are some of the examples mentioned to change password of the MyDB.mdb database to "MyPassword2" from "MyPassword1":

Code:
   Sub ChangeDBPassword ()
      Dim Db As Database

      Set Db = OpenDatabase("C:\My Documents\MyDB.mdb",True, _
         False,";pwd=MyPassword1")
      Db.NewPassword "MyPassword1","MyPassword2"
      Db.Close
   End Sub
If a wrong password is used then the above code will not handle the possibility of trying to open the database and it will just output an error. Every application that tries to open password protected databases should be able to handle this scenario.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to Code a change password form in vb6"
Thread Thread Starter Forum Replies Last Post
old password usable after a password change ADAMEE Active Directory 1 22-05-2011 06:05 AM
Need Password Reset Disk to change password for Windows 7 Alfanumeric Operating Systems 3 11-01-2011 03:06 PM
Access vba code form issue Jaiwanti Software Development 3 06-07-2009 12:32 PM
Change password for users with blank password: Error Ihit Active Directory 3 06-06-2008 06:21 PM
Change password/disable account - password cached? gbug Active Directory 3 25-04-2008 05:09 AM


All times are GMT +5.5. The time now is 11:34 PM.