Jump to content

A simple Log In screen

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
Clawbo

Clawbo

    Newbie

  • Members
  • Pip
  • 7 posts
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:


        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()

And that's it! Hope it Helps!

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Interesting bit of code. What if you wanted to have multiple users and passwords or allow users to add/change users and passwords?

#3
Clawbo

Clawbo

    Newbie

  • Members
  • Pip
  • 7 posts
I would added an "Or" in the "If" bit.

#4
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,248 posts
What if you have 300 users though?

#5
Clawbo

Clawbo

    Newbie

  • Members
  • Pip
  • 7 posts
Guys, I'm new. I don't know :P

#6
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,248 posts
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.

#7
Clawbo

Clawbo

    Newbie

  • Members
  • Pip
  • 7 posts
Thanks guys, I'll be sure to do that.