Hey, I don't know if this already exists, but here it is anyway.
First off, add two labels, two text boxes, and one button. Place them as you want, and make one label say "Username:" and the other one "Password:"
Make the button say "Log In".
Here's what I did (remove the space after the first h):
h ttp://i39.tinypic.com/j6h1mf.jpg
Now, Double click the button, and insert this code:
And that's it! Hope it Helps!Code:Dim usrValid As Integer Dim pswdValid As Integer usrValid = False pswdValid = False If TextBox1.Text = "(Your username here)" Then usrValid = True If TextBox2.Text = "(Your pass here)" Then pswdValid = True If usrValid = True And pswdValid = True Then (name of your form).Show() Me.Close()
Interesting bit of code. What if you wanted to have multiple users and passwords or allow users to add/change users and passwords?
I would added an "Or" in the "If" bit.
What if you have 300 users though?
Guys, I'm new. I don't know![]()
Just pointing out that it's not very practical.
Although you got the basics of how log in forms should work which a great start.
One thing that I want to point out, you should name your controls better. When I look at the name of a control, I should be able to pick out this information:
- The type of control (e.g. radio button, text box, etc)
- The type of information inputted using that control.
So instead of TextField1 for the user name a better name would be: txtUsername
I can pick out that it's a text field and is used for inputting a user name.
It also makes your code easier to understand.
Thanks guys, I'll be sure to do that.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks