Page 1 of 2

Remember Me Function

Posted: Fri Nov 27, 2009 8:39 pm
by MasterCoding
I gonna learn you how to add a remember me function to your application

whe need

3 textboxes
Name Textbox1 to username
Name Textbox2 to Password
and name textbox3 to Nothing1
and make nothing1 then to visible false

1 checkbox
change the text to Remember Me

2 labels(optional)
label1 change the text to username
label2 change the text to password

lets start

with my project settings
and add this settings
Image

and then code it
the hole code here i don't wanna do it in parts the code because some begginers don't know where the options are(dont know how to say it else that options)
Code: Select all
Public Class Form1

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked = True Then
            My.Settings.RememberMe = True

        End If
        If CheckBox1.Checked = False Then
            My.Settings.RememberMe = False
        End If
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If My.Settings.RememberMe = True Then
            My.Settings.Username = Username.Text
            My.Settings.Password = Password.Text
        End If
        If My.Settings.RememberMe = False Then
            Nothing1.Text = My.Settings.Username
            Nothing1.Text = My.Settings.Password
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If My.Settings.RememberMe = True Then
            Username.Text = My.Settings.Username
            Password.Text = My.Settings.Password
            CheckBox1.Checked = True
        End If
        If My.Settings.RememberMe = False Then
            My.Settings.Username = Username.Text
            My.Settings.Password = Password.Text
            CheckBox1.Checked = False
        End If
    End Sub
End Class

Re: Remember Me Function

Posted: Fri Nov 27, 2009 8:55 pm
by Nery
Instead of making 2 IF Statements do the following (there are bad habits you should take care of like the "If Checkbox1.Checked = False"
Code: Select all
If Not Checkbox1.Checked Then
      Me.Settings.RememberMe = False
Else
      My.Settings.RememberMe = True
End If
Thats the correct way (It's simplier and thats how professionals do)

Re: Remember Me Function

Posted: Fri Nov 27, 2009 9:04 pm
by MasterCoding
damned i never have thinked about that

Re: Remember Me Function

Posted: Wed Dec 02, 2009 12:41 am
by Robby
good job! this is really good. and yes u should use the cod that nery has it is shorter,better and pro.

try to keep ur code the shorest it can go to so if ypu give out a source the person can read ass it aint too much

Re: Remember Me Function

Posted: Wed Dec 02, 2009 7:21 pm
by Nery
Yes, check the video link I've posted: viewtopic.php?f=35&t=623 It may help you.

Re: Remember Me Function

Posted: Sat Dec 26, 2009 2:21 pm
by Usman55
Hello everyone!
I have a request for you all...
Please put a detail of at least 2 lines in the top of your tutorial that what the program actually does!
I hope you will accept this...
Bye everyone!

Re: Remember Me Function

Posted: Sat Dec 26, 2009 2:23 pm
by Usman55
Hello!

I also want to say that we should improve our grammar... It is really important!

Thanks!

Re: Remember Me Function

Posted: Sat Dec 26, 2009 3:03 pm
by Nery
"I gonna learn you how to add a remember me function to your application"

Its not "I gonna learn you"... its "I'm going to teach you" or "I'm gonna teach you".

Re: Remember Me Function

Posted: Sun Dec 27, 2009 12:18 am
by MasterCoding
i maked this code just like this so i don;'t know it anymore actuly

ps. im very sleepy its really late now 1:18

Re: Remember Me Function

Posted: Sun Dec 27, 2009 12:23 am
by Toxikr3
Usman55 wrote:
Hello everyone!
I have a request for you all...
Please put a detail of at least 2 lines in the top of your tutorial that what the program actually does!
I hope you will accept this...
Bye everyone!

"Remember me function" makes perfect sense to me about the content of this thread...

Also, very helpful tutorial, thanks!

-Toxikr3