473,785 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Login for a password form...multiple users

Hi, I am a beginner and below I have code for a long in form. My goal is
for the form to read a file of a list of users and thier passwords
....compare the text box inputs to the file and either start over or load the
main file.... I attempted to use a slect case..but its not working for me..
If someone has a better way of doing it..I would apperciate the help. Thank
you!

Option Explicit

Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click ()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
Me.Hide
End Sub

Private Sub cmdOK_Click()
Dim User As String
Dim Password As String
Dim inCtr As Integer
Dim LoginSucceded As Boolean
Dim Login

Login = User + Password
Select Case LoginSucceded
'demo not a variable....exa mple..txt.Usern ame.text is what is needed

Case Demo

User = txtUserName = "Trial"
txtPassword = "Demo"
Form_Load.frmDa ta
Me.Hide

Case File
Open "C:\Windows\Dat aPwd\Pswd.pwd" For Random As #1
For i = 1 To 10
Get #1, User, Password
If Text.txtUserNam e = User And Text.txtPasswor d = Password Then
LoginSucceeded = True
Form_Load.frmDa ta
Me.Hide
Else: Next i
End If
Else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.Set Focus
SendKeys "{Home}+{En d}"
End If
End Sub

Oct 25 '05 #1
1 13071
If this is your exact code, you have problems all over the place..

Your Select Case does not have a matching End Select

Also, you have 2 variables
- A module level variable called LoginSucceeded
- A procdure level variable called LoginSucceded
You are just asking for all kinds of debugging trouble by having 2 variable
named so similarily
- Why are you doing a
Select Case LoginSucceded ?
You are using the procedure level variable, and when the procedure is
entered (i.e., after the cmdOK is clicked), this variable will ALWAYS be
false.
The "Select Case LoginSucceded" makes no sense

- On the Case statements, Demo and File are not variables, if you intend for
these to be strings, you have to enclose these in double-quotes, use "Demo"
and "File".

- If you want to check the UID and PWD that a user enters, you will want to
open your file first, read it to see if the txtUserName.Tex t and
txtPassword.Tex t exist in the data file. If so, all is good, if not make the
user re-enter.

- I think you are trying to highlight the contents of the txtPassword
textbox by
SendKeys "{Home}+{En d}"
- You should do the following
txtPassword.Set Focus
txtPassword.Sel Start= 0
txtPassword.Sel Length = Len(txtPassword .Text)

Try to straighten up some of that, and see how that goes

Mike

"william cline" <wi****@earthli nk.net> wrote in message
news:7W******** ***********@new sread2.news.atl .earthlink.net. ..
Hi, I am a beginner and below I have code for a long in form. My goal
is
for the form to read a file of a list of users and thier passwords
...compare the text box inputs to the file and either start over or load
the
main file.... I attempted to use a slect case..but its not working for
me..
If someone has a better way of doing it..I would apperciate the help.
Thank
you!

Option Explicit

Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click ()
'set the global var to false
'to denote a failed login
LoginSucceeded = False
Me.Hide
End Sub

Private Sub cmdOK_Click()
Dim User As String
Dim Password As String
Dim inCtr As Integer
Dim LoginSucceded As Boolean
Dim Login

Login = User + Password
Select Case LoginSucceded
'demo not a variable....exa mple..txt.Usern ame.text is what is needed

Case Demo

User = txtUserName = "Trial"
txtPassword = "Demo"
Form_Load.frmDa ta
Me.Hide

Case File
Open "C:\Windows\Dat aPwd\Pswd.pwd" For Random As #1
For i = 1 To 10
Get #1, User, Password
If Text.txtUserNam e = User And Text.txtPasswor d = Password Then
LoginSucceeded = True
Form_Load.frmDa ta
Me.Hide
Else: Next i
End If
Else
MsgBox "Invalid Password, try again!", , "Login"
txtPassword.Set Focus
SendKeys "{Home}+{En d}"
End If
End Sub


Oct 25 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2972
by: David W. Simmonds | last post by:
I have a form that will prompt for a user name/password. In VS.NET, I have the protected form in a folder named Admin. I have a Web.config file in that folder as well. It contains the following section: <authorization> <deny users="?" /> <allow users="*" /> </authorization> In the root folder where the other forms are located I have a Web.config
7
1539
by: Cemal Karademir | last post by:
Hi, I'm workin on a small Login page/program with asp.net. It uses an MS-Access database that looks like this: USERID | NAME | PASSWORD _________________________________ 1 | John | hello 2 | Paul | hello2 I don't understand why it doesn't work. I think i'm doing something wrong
3
2155
by: bill | last post by:
I need to open a asp.net web form from a classic asp page, and pass a username and password to the asp.net page. The username and password exist as session variables in the classic asp application. I can't put the password in the classic asp page form as a hidden field and submit it, because someone can view source and see the password. This is a security problem I encounter in a mixed classic asp and asp.net environment. I don't...
18
3397
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site relies on subscrption fees. Sessions ID's are matched between the browser and the server. So a users can login with same username and password and those sessions are tracked individually. Some suggest create table fields with the session ID...
2
1933
by: dylanhughes | last post by:
I'm looking for an example of a login system that has multiple fields (2 to be exact) + password. e.g username, company name and password, the user, company and password are checked against a mysql database. I have it working with just the username field but I'm confused on how to go about adding another field. I'm pretty new to PHP so don't beat me up too much for this example code, I borrowed and hacked it together in a very short period...
3
2327
by: Jennifer.Berube | last post by:
okay...so I got this login script and I edited it all and it seems to run fine...IE it listens to the script as far as permissions go when I place a restriction on a page and when you login it redirects. But first it doesn't tell you that you're logged in and doesn't provide a logout feature. And most importantly if I type in a random username and password not listed in the database it doesn't seem to matter it still "lets me login"
12
3600
by: Fareast Adam | last post by:
I want to make sure all users those login are different in a time either on the same or different computer or web browser. Following are sample of my program which consist 4 different pages; #users.php $users = array( 'user1' => md5('password1'), 'user2' => md5('password2') ); $salt = substr(md5(date('F')), 8);
9
7813
by: Josh | last post by:
I run a Joomla website and am familiar with php in some but not all aspects. Currently I am trying to find some solutions related to session handling. Am I correct in saying that "login" is kept in sessions? I can see active sessions in my mysql database, but is that the only place this information is stored? Sessions and cookies I know are related also, but how specifically (session info stored in cookies?)? Right now, when users...
13
4176
by: Apostle | last post by:
Hi all, after thinking for sometimes, I thought it will be great opportunity to learn if I will start from scratch and build my own register/login system. Here is the thread that I will be posting the progress and I hope you guys will help me. The code below is what I have so far. Just put two scripts in the same directory and that is! I hope you will help me Thanks! class.php <?php //php login sytem class LoginRegister{ function...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.