Skip to main content

Login using a Text File Database in VB6

In this tutorial, we will going to make a program that has a text file database which will be going to use as our database of the program.

Now, let's start this tutorial!

1.Let's start this tutorial by following the following steps in Microsoft Visual Basic 6.0: Open Microsoft Visual Basic 6.0, click Choose Standard EXE, and click Open.

2.Next, add only one Button named cmdOK and labeled it as "OK". Add two textbox named txtUser for inputting the username and txtPass for inputting the password.You must design your interface like this:


3. Open a notepad and on it type:

Save it as Security.txt.

4.Now put this code for your code module. This code is for cmdOK_Click:

  1. Private Sub cmdOk_Click()
  2. Open "Security.txt" For Input As #1
  3. Do Until EOF(1)
  4. Input #1, user, pass
  5. If txtUser.Text = user And txtPass.Text = pass Then
  6. MsgBox "W E L C O M E", vbInformation
  7. Exit Sub
  8. End If
  9. Loop
  10. MsgBox "A C C E S S D E N I E D", vbInformation
  11. Close #1
  12. End Sub


We have created a syntax for opening our text file named Security.txt and as For Input As #1. The Open Statement here enables input/output (I/O) to a file. The Open statement syntax has these parts: Pathname - string expression that specifies a file name — may include directory or folder, and drive, Mode - keyword specifying the file mode: Append, Binary, Input, Output, or Random. If unspecified, the file is opened for Random access, Access - keyword specifying the operations permitted on the open file: Read, Write, or Read Write. The #1 here in the code means reading of the text file. The we have created an EOF Do Until Loop. EOF returns a value that indicates whether the current record position is after the last record in a Recordset object. Then we make variables user and pass as our input that is equal to the content of the text file to be read. And if it is equal txtUser and txtPass respectively, then it will prompt the user to "Welcome". Otherwise, it will diplay "Access Denied". The close statement here closes the text file at the end of a request and releases resources.





Download the source code and try it! :)

For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.

Best Regards,

Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]

Add and Follow me on Facebook:

Visit and like my page on Facebook at:

Visit my website at:

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.


1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.