Jump to content
  • Advertisement
Sign in to follow this  
Dj_aLek

Login function

This topic is 5407 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm programming in Visual basic. It's no problem making a Login function, but my problem is to hav a easy way to add users and their passwords... Here's the code block: Dim Usr, Pass Usr = "alek" Pass = "psw" If txtUserName = Usr If txtPassword = Pass Then LoginSucceeded = True Load Form1 Form1.Show Unload frmLogin Else MsgBox "Wrong password, try again!", , "Login" txtUserName.SetFocus SendKeys "{Home}+{End}" End If Anyway to add more users without many Else If test?? Thankz for any replies...

Share this post


Link to post
Share on other sites
Advertisement
I don´t remember Visual Basic´s syntax that well so here´s just an explanation:

Put users and passwords in to the arrays and then loop through them.

Share this post


Link to post
Share on other sites
An easy way would be to have an array of usernames and passwords. Then you can just use a loop to cycle through each entry in the array to check whether it matched the entered username and password.

I think that the way rpofessional software does it (although im not sure) is to have a database of usernames and passwords (which is probably goin to end up in an array anyway once its loaded) to store the passwords and load it at run time.

I think the array would be your best bet to try out for now though:)

EDIT: beaten to it lol

Share this post


Link to post
Share on other sites
Quote:
Original post by grekster
I think that the way rpofessional software does it (although im not sure) is to have a database of usernames and passwords (which is probably goin to end up in an array anyway once its loaded) to store the passwords and load it at run time.


It's actually not necessary for the application to store the list at all. You can just tell the database 'send me the password for user X' and compare it (with appropriate security precautions blah blah). One advantage is that no special handling is needed to allow users to be added or passwords changed while the program is running.

There are ways of doing all this in VB but it's extreme overkill for a simple app.

Share this post


Link to post
Share on other sites
thankz for the replies...
One question though. I'm a noob, this is actually my first app.
What exactly do you mean by an array..? I'm not that good at looping yet.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dj_aLek
What exactly do you mean by an array..? I'm not that good at looping yet.


lol, looping takes some practice to get good at :P

An array is a continuous block of memory which stores some variables of the same type under a single name. To reference each variable you use an index:

Dim a(100) as Integer

will create the array "a" which contains 100 integers. These integers' indices will be from 0 to 99.

a(i) will reference the i_th integer in a
(if this 0-99 indice numbering is confusing you can use
"Option Base 1" to make them be from 1 to 100).

Now to parse the array you use a loop:

For i = 0 to 99
//do stuff with a(i)
Next

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!