This is my first tutorial, so if there are any mistakes please forgive me =).
This will show you a very simple way to read your Login information from an outside text file.
What you need:
1. Add a new "Login Dialog" form to your project.
2. Completely erase the code inside of it, but keep the interface.
3. Create a text file listing your usernames and passwords one line after the other.
Your text file should look like this (without the numbers in front of the names): -
Username1
-
Password1
-
Username2
-
Password2
-
Username3
-
Password3
Etc...
Now, paste this code into your Login form. - Dim nFileNum As Integer, UInfo(999, 2) As String, sNextLine As String, lLineCount As Long, NumLine As Integer, LCount As Integer, UnPw As Integer, UnCheck As Boolean, PwCheck As Boolean, UserNum As Integer
-
-
Private Sub Form_Load()
-
UnCheck = False
-
PwCheck = False
-
-
nFileNum = FreeFile
-
-
Open "C:\Documents and Settings\Matt\My Documents\testing.txt" For Input As nFileNum
-
lLineCount = 1
-
-
NumLine = 0
-
LCount = 1
-
UnPw = 0
-
-
Do While Not EOF(nFileNum)
-
Line Input #nFileNum, sText
-
LCount = LCount + 1
-
If LCount Mod 2 <> 0 Then UnPw = 2
-
If LCount Mod 2 = 0 Then
-
NumLine = NumLine + 1
-
UnPw = 1
-
End If
-
UInfo(NumLine, UnPw) = sText
-
Loop
-
-
End Sub
-
Private Sub cmdCancel_Click()
-
Me.Hide
-
End
-
End Sub
-
-
Private Sub cmdOK_Click()
-
'check for correct password
-
For x = 1 To LCount
-
If txtUserName = UInfo(x, 1) Then
-
UnCheck = True
-
UserNum = x
-
End If
-
Next x
-
-
If txtPassword = UInfo(UserNum, 2) Then PwCheck = True
-
-
If txtUserName = "" Then
-
MsgBox "Invalid Username or Password, try again!", , "Login"
-
txtPassword = ""
-
txtPassword.SetFocus
-
SendKeys "{Home}+{End}"
-
ElseIf txtPassword = "" Then
-
MsgBox "Invalid Username or Password, try again!", , "Login"
-
txtPassword = ""
-
txtPassword.SetFocus
-
SendKeys "{Home}+{End}"
-
ElseIf UnCheck And PwCheck = True Then
-
MAINFORM.Visible = True
-
Me.Enabled = False
-
Me.Hide
-
Else
-
MsgBox "Invalid Username or Password, try again!", , "Login"
-
txtPassword = ""
-
txtPassword.SetFocus
-
SendKeys "{Home}+{End}"
-
End If
-
-
End Sub
Now, you are almost done.
1. Go to line 9 and change the filepath to where your text file resides.
2. Go to line 55 and change "MAINFORM" to your form that you would like to show.
Now you SHOULD be done! The way the program is written, you may have up to 999 sets of usernames and passwords.
The only problem with this is that if somebody knows where your text file is, they have all your passwords! Luckily the program I am using this for just HAPPENS to be an encryption program, so I can simply encrypt the text file. Once I have finished this I will repost on how it is done.
4 9700
Thanks for that, ldpfrog
When I have the time one of these weekends, I may edit the article, just for consistency with various others here - one of the benefits of being a moderator. :)
I'd like to point out though, in any such case, the most basic security measure would be to store the encrypted version of each password in your file, not the "clear" version. That way, reading the file will not tell people your passwords, unless they figure out how to decrypt them. And if they wanted to edit the file to allow themselves access, they would have to encrypt their password, your way, for it to work. Certainly not impregnable, but definitely tougher than just reading the file.
can you able to explain this code then it'll be good to get the things clear?
How to make it read the text file is the data is printed like this
"username1","pa ssword1"
"username2","pa ssword2"
etc.
How to make it read the text file is the data is printed like this
"username1","pa ssword1"
"username2","pa ssword2"
I'd look into using the Input # statement, instead of Line Input #.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Siobhan |
last post by:
Hi
What is the recommended way to store a user's database credentials across
the pages of a web application so that each time the database is accessed the
system doesn't have to ask them for their username and password again
We have previously stored these in a session variable (encrypted) and
retrieved from their - but are worried about the...
|
by: serge calderara |
last post by:
Dear all,
I need to build a web application which will contains articles (long or short)
I was wondering on what is the correct way to retrive those article on web
page.
In orther words, when there is such information to be displayed are they
coming from imported files, database ?
Where and how this type of information is stored ?
What...
|
by: Daniel Sélen Secches |
last post by:
I found a good class to do a simple FTP.
Very good....
I'm posting it with the message, i hope it helps someone
==============================================================
Imports System.Net
|
by: XML newbie: Urgent pls help! |
last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it
verifies the login information it should display the SessionID and enable
some button . I appreciate your help and thanku in advance
When I run the pgm , I get the error:
Can't parse login information. Object Reference not set to an instance of an
object. I have...
|
by: carmstrong |
last post by:
I'm new to PHP and I'm trying to write up a simple PHP login page
script to authenticate users from a flat file. I've managed to make
most of it work, except that it only accepts the last user on the
user/password file, and I'm not sure why. (I.e. the user.txt file is:
user1:pass1
user2:pass2
user3:pass3
and it only works for...
| |
by: bobmct |
last post by:
Again: struggling to convert old-style HTML to html using css.
I am trying to create a rectangular box divided into approx three vertical
sections. The top section contains an image I would like on the extreme
left of the box, the text centered in the reamaining space in that section.
The center third contains two lines prompting for a...
|
by: trint |
last post by:
Hi,
I need to have a "remember my login" cookie if someone checks the
checkbox.
The checkbox's text is "Remember Me on this Computer"
The login users name is their email (like):
users name: trinity@gmail.com
password: windintrees
If the cookie exists, open and read if it has a "1" to load
the login information, or "0" for no...
|
by: carl2k2 |
last post by:
Ok First I have a very simple way of entering data into a form and saving that into a text file,
I made two text files for username(text1) and password(text2), I would like to make a simple login with the outcome out this,
Code for Registration:
Dim savefile As Long
savefile = FreeFile()
Open "I:\College Work ------- Updated 2008...
|
by: satishknight |
last post by:
Hi,
Can some one tell me how to change the validation sequence for the code pasted below, actually what I want it when any one enters the wrong login information (already registered users) then it has to tell then them its wrong information but currently it takes then to a next page and then tells them its incorrect information. This is tedious...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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. ...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |