Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 122
  • Last Modified:

Split Reader

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
Aioreyn
Asked:
Aioreyn
1 Solution
 
DocMCommented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now