Login using a Text File Database in VB6

Submitted by: 
Visitors have accessed this post 2082 times.

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: https://www.facebook.com/donzzsky

Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.