login problem

daveofgv

Well-known member
Joined
Sep 17, 2008
Messages
218
Location
Dallas, TX
Programming Experience
1-3
Hello All,

I hope this is in the right forum....

I have a login form that is connected to a my.settings (internal) hashcode.
When I type the correct info in my usertextbox and passtextbox my program starts. Everything works perfect except that when I run the program again the username and password is already in the textbox's.

On another form I have a my.settings.save(). Every my.settings in my app I need to save except the login info.

Is there anything I can put on the login form to clear those two textbox's and keep everything else the same???

The code on my login form right now is:

VB.NET:
If TextBox1.Text = My.Settings.username Then
            CopyrightScreen.Show()
        Else
            MessageBox.Show("You entered the wrong username")
        End If
        If TextBox2.Text = My.Settings.password Then
            CopyrightScreen.Show()
        Else
            MessageBox.Show("You entered the wrong password")
        End If

Thanks in advanced

daveofgv
 
Last edited:
I would think the easiest way would be to add code clearing those two settings as soon as the logon is complete. This way, you won't have to change any previous coding.:D
 
Thank you for your reply.

That was basically my question. I know code would be the easiest, however, I would like to ask how to add the code to clear the textbox's (username/password) without having to clear "all" my settings. I have about 25 forms and hundreds if not more code all ready in place. I have been messing with the login form for a while now and have decided to post my question since all my remedies have been exhuasted on this issue.

The code above actually is wrong since it's not doing what I wanted it to do anymore. I have to re-code that part, but would like some help on clearing it.

Actually, maybe a different way to explain this is that when the login form opens the username and password is already in the textbox's. I need it so the username/password is not there and the textbox's are empty when the form is opened.

Thank you

daveofgv
 
Personally, I do two things.

First, I don't load the textboxes with values. Therefore, they just show as blank.

Second, as soon as the logon is complete, I clear the settings.
VB.NET:
My.Settings.UserName = ""
My.Settings.Password = ""

I only allow those particular settings to have a very short life span.
 
I used the internal hashcode in the immediate window:

VB.NET:
?"password".GetHashCode()

and placed the value number in the value spot of the my.settings. This is making the value appear everytime the form opens.

Any suggestions about this?
 
Sorry, I made an assumption with my previous post which may have led to a miscommunication on my part.

Just to clear things up, is this logon just for access to your program or are you using these later for access to something else?

If this is just for access to your program, why capture them at all? Either they pass to the next form or they fail and don't go anywhere.

If you are using them for access to something else later in your program, it would probably be more secure to create global variables that are destroyed when the program closes.
 
This particular one will be used to enter my program. Also, I will be using one to enter a particular section and a change username/password form as well, but I am not really worrying about that one until I get my project done so I can decide which forms will be protected.

I should be pretty good on the change username/password with the following code:

VB.NET:
   If newpass1TextBox.Text = newpass2TextBox.Text AndAlso oldpassTextBox.Text.GetHashCode() = My.Settings.PasswordHashCode Then

            My.Settings.PasswordHashCode = newpass1TextBox.Text.GetHashCode()

            MessageBox.Show("Password changed")
        Else
            MessageBox.Show("New Passwords don't match or old password is wrong")
        End If

Unless you have a better way of doing it. Then I am always up for improvments...lol


daveofgv
 
Back
Top