?
Solved

Split Reader

Posted on 2003-03-06
1
Medium Priority
?
121 Views
Last Modified: 2010-05-01
Working on a security system that reads a text file. I have the inpute set up, but when it ges to read the file, the split command gives me the error either " Input past end of file" or "Subscript Unreachable". the format of thel ine I need to read is as follows:

UserName<>UserPass<>AccessLevel

 Here's the command code:

//////////////////////////////////////////////////////
Private Sub cmdOK_Click()
   sUsername = txtUserName.Text ' used later in program, required line
Open sPWL For Input As 1 ' sPWL == App.Path + \Data1.dat
Line Input #1, sTemp ' used to skip Input marker past first line, which contains authorization code.
Do Until EOF(1)
Do While InStr(1, sTemp, vbCrLf) = 0 ' Meant to end at each line
Input #1, sTemp
If txtName.Text = Split(sTemp, "<>")(0) And txtPass.Text = Split(sTemp, "<>")(1) Then
frmLogin.Visible = False
frmMain.Visisble = True
Loop
Loop
Close 1
End Sub
////////////////////////////////////////////////////////

Any help with why it gives me these error messages would be greatly appreciated. Probably something simple, I still pretty new to this.
0
Comment
Question by:Aioreyn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
DocM earned 80 total points
ID: 8085220
With the inside loop

Do While InStr(1, sTemp, vbCrLf) = 0 ' Meant to end at each line
Input #1, sTemp
Loop

you reach the end of the file without testing the EOF.

Try this:
Open sPWL For Input As 1 ' sPWL == App.Path + \Data1.dat
Line Input #1, sTemp ' used to skip Input marker past first line, which contains authorization code.
While EOF(1) = False
Input #1, sTemp
If txtName = Split(sTemp, "<>")(0) And txtPass = Split(sTemp, "<>")(1) Then
frmLogin.Visible = False
frmMain.Visisble = True
End If
Wend
Close 1
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question