473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

changing the password/user name in VB6 runtime

Hi all,
i am writing a program in vb6. i need to change the login user name and the password. I did it. but the problem is when i run the program again the changes are not saved. the code is as follows. pleas help me as wht is wrong there. I need to save the changed user name and password and save them in two variables and take them as the user name and the password.




Dim x As String
Dim y As String




Private Sub cmdbackto_Click()
frmpwun.Visible = False
End Sub


Private Sub cmdok_Click()

If (txtun.Text = x) Then
If (txtpw.Text = y) Then
Unload Me
Load MainForm
MainForm.Visible = True


Else
msg = MsgBox("Invalid Password", vbOKOnly + vbCritical, "Authentication")
txtpw.SetFocus
txtpw.Text = ""
End If
Else
msg = MsgBox("Invalid User name", vbOKOnly + vbCritical, "Authentication")
txtun.SetFocus
txtun.Text = ""
txtpw.Text = ""
End If
End Sub


Private Sub cmdpwun_Click()

If (txtun.Text <> x) Then
msg = MsgBox("Please enter the correct user name", vbExclamation, "User Name")
Else
If (txtpw.Text <> y) Then
msg = MsgBox("Please enter the correct password ", vbExclamation, "Password")
Else

frmpwun.Visible = True

End If
End If




End Sub

Private Sub cmgchange_Click()
If (txtunchange.Text = "") Then
msg = MsgBox("Please enter the new user name", vbExclamation, "User Name")
Else
If (txtpwchange.Text = "") Then
msg = MsgBox("Please enter the new password ", vbExclamation, "Bay")
Else


msg = MsgBox("Do you want to save the changes", vbExclamation + vbOKCancel, "Edit Authentication")
If (msg = vbOK) Then
x = txtunchange.Text
y = txtpwchange.Text
msg = MsgBox("Modifications are successfully saved ", vbExclamation, "Authentication")
txtunchange.Text = ""
txtpwchange.Text = ""
End If
End If
End If
End Sub

Private Sub Form_Load()
frmpwun.Visible = False
txtun.Text = x
txtunchange.Text = x
End Sub

Private Sub txtpw_Change()
'cmdok.SetFocus
End Sub
Mar 16 '11 #1
2 3555
Guido Geurs
767 Expert 512MB
You have to save it in a file or in the registry because the data set in a session is not saved in the Exe.

To write to a file you can use:
Expand|Select|Wrap|Line Numbers
  1. Dim OUTPUTFN As Integer
  2.    OUTPUTFN = FreeFile
  3.    On Error GoTo ErrWriting
  4.    Open App.Path & "\settings.ini" For Output As #OUTPUTFN
  5.       Write #OUTPUTFN, txtpw.text
  6.       Write #OUTPUTFN, txtun.text
  7.    Close #OUTPUTFN
  8. Exit Sub
  9. ErrWriting:
  10.    Close #OUTPUTFN
  11.    MsgBox ("There is an error writing the settings file !")
To load it at startup:
Expand|Select|Wrap|Line Numbers
  1. Dim INPUTTEXT As String
  2. Dim INPUTFN As Integer
  3.    INPUTFN = FreeFile
  4.    On Error GoTo ErrReading
  5.    Open App.Path & "\settings.ini" For Input As #INPUTFN
  6.       Input #INPUTFN, input_txt
  7.       txtpw.Text = input_txt
  8.       Input #INPUTFN, input_txt
  9.       txtun.Text = input_txt
  10.    Close #INPUTFN
  11. Exit Sub
  12. ErrReading:
  13.    Close #INPUTFN
  14.    MsgBox ("There is an error reading the settings !")
PS: because it's a password and login: you have to scramble the data (the file "settings.ini" is readable with an editor !!!
Mar 16 '11 #2
Rabbit
12,516 Expert Mod 8TB
A common method is to hash the password. Of course, like with all things when you store that information locally, all a user needs to get around it is to change the file and no more password.
Mar 16 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: hkadhim | last post by:
hi all, I am trying to validate a user name and password using server 2000 domain validation. so users would use their normal ID and passwords to login. does anyone know how to do it or have any...
3
by: eastcoastguyz | last post by:
On an Apache server, I want to be able to have a user name/password directory. I know this can be done with .htaccess, but I want to be able to do this for multiple users. The purpose of this, is...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
5
by: Markus Stehle | last post by:
Hi all! I have asp.net web application that uses static impersonation. Is it possible to change the impersonated user during runtime? Within some parts of my application I would like to...
1
by: Nick via .NET 247 | last post by:
I have a similar problem trying to use web services with awindows form application. I currently use a static web referencein my project. What I am trying to do is to programaticallychange the url...
1
by: VB Programmer | last post by:
Using ASP.NET 2.0 Web Site Admin Tool. Under Security tab it says this: Click a row to select a user and then click Edit user to view or change the user's password or other properties. When...
0
by: Jack Russell | last post by:
It would be appear that users have two names, UserName and UserFullName. This can be demonstrated by changing a user name then getting a list of users (see code below) However the only way I...
4
by: muchexie | last post by:
I have developed a login system but its failing to allow the user to change password. Here is my code. <? require_once("system_fns.php"); session_start(); do_html_header("Changing...
0
by: =?Utf-8?B?RWQgT3R0bw==?= | last post by:
When changing a user's password in Active Directory Users... I get a strange error message (and the password change fails): Windows can not complete the password change for the user <insert user...
3
by: swetha123 | last post by:
hello, I don't know how to use cookies please help me in this I am using the dream weaver cs4 I designed the navigation bar to my page using dream weaver cs4 navigation bar contains...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.