Mirage Engine
Remember password & username - Printable Version

+- Mirage Engine (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49)
+---- Thread: Remember password & username (/showthread.php?tid=780)



Remember password & username - Braydok - 03-03-2007

Difficultly: 1/5
Time: Three minutes

Hello, I am completely new here, but I know my way around VB6 a little, so I worked up a code that remembers your username and password if you check a button.
Here goes:

OK, first open up your frmLogin and add a check box and call it RPass. Then double click on the connect button and add this code to the top, right under the Private sub picConnect_click():

Code:
If RPass.Value = 1 Then
Open "Data.ini" For Output As #f
Print #f, "[SETTINGS]"
Print #f, "Last User= "
Print #f, txtName
Print #f, "Last Password= "
Print #f, txtPassword
Close #f
Else
End If

Then add this into the form_load()

Code:
f = FreeFile

Dim n
Dim O
Dim usr
Dim t
Dim pass
On Error GoTo Error
Open "Data.ini" For Input As #f

Input #f, n
Input #f, O
Input #f, usr
Input #f, t
Input #f, pass
Close #f
RPass.Value = 1
txtName.Text = usr
txtPassword.Text = pass
Error:

Then up at the top, write this in:
Code:
public f as Integer

That works for me.

Just make sure to keep the Trim part of the code there.
That should do it, but you might have to create a file called data.ini, because it might runtime.

~Braydok


- William - 03-03-2007

It's nice to see that you are trying to share your code. Although there are a few things thats wrong. I suggest you test it before sharing it Tongue


- Robin - 03-03-2007

My votes winning!


- Braydok - 04-03-2007

William Wrote:It's nice to see that you are trying to share your code. Although there are a few things thats wrong. I suggest you test it before sharing it Tongue

Shoot you, I did test it, did you think I would not test it?


- William - 04-03-2007

Bah, the code you supplied will only save it. Not load it into the text boxes.


- Robin - 04-03-2007

Braydok Wrote:
William Wrote:It's nice to see that you are trying to share your code. Although there are a few things thats wrong. I suggest you test it before sharing it Tongue

Shoot you, I did test it, did you think I would not test it?


Yes. We obviously think you didn't test it because it doesn't work.


- Braydok - 04-03-2007

Shit, your right, forgive me, here is the full code:

In the sub connect_click()
Code:
Private Sub picConnect_Click()
If RPass.Value = 1 Then
Open "Data.ini" For Output As #f
Print #f, "[SETTINGS]"
Print #f, "Last User= "
Print #f, txtName
Print #f, "Last Password= "
Print #f, txtPassword
Close #f
Else
End If

Then add this into the form_load()

Code:
f = FreeFile

Dim n
Dim O
Dim usr
Dim t
Dim pass
On Error GoTo Error
Open "Data.ini" For Input As #f

Input #f, n
Input #f, O
Input #f, usr
Input #f, t
Input #f, pass
Close #f
RPass.Value = 1
txtName.Text = usr
txtPassword.Text = pass
Error:

Then up at the top, write this in:
Code:
public f as Integer

That works for me.
Is this code good?


- Braydok - 04-03-2007

Uh, yeah, I am still new at VB6, just started getting into it one week ago, so I don't know all the PutVar and stuff, so I'll work on that, thanks.

~Braydok