-
I'm using VB 6.0. I'm doing a simple read from a text file. My partial code looks like this:
Line Input #nInvFile, sInvTemp
While Not EOF(nInvFile)
Line Input #nInvFile, sInvTemp
FrmBorwr.CboInvestors.AddItem sInvTemp
Wend
I get an error message saying: !Compile error. Expected array (referring to EOF).
Can someone help me? Thanks in advance.
Madi
-
try this
Code:
Open "C:\YourText.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strTemp
FrmBorwr.CboInvestors.AddItem strTemp
Loop
-
What you show looks OK to me, but have you opened the file? Please post more of your code if that's not the problem.
-
My code looks like this:
Sub GetInvestors()
Dim sInvTemp As String, sInvestorFile As String
CboInvestors.Clear
sInvestorFile = FrmMain.sApp_Path & "INVESTOR.TXT"
nInvFile = FreeFile
Open sInvestorFile For Input As #nInvFile
Do While Not EOF(nInvFile)
Line Input #nInvFile, sInvTemp
FrmBorwr.CboInvestors.AddItem sInvTemp
Loop
Close #nInvFile
End Sub
I get a compile error: Expected array (referring to EOF)
Investor.Txt lists name of investors:
INVESTOR A
INVESTOR B
INVESTOR C
I can change the code to this and not get an error:
Do While sInvTemp <> "[EOF]"
Line Input #nInvFile, sInvTemp
FrmBorwr.CboInvestors.AddItem sInvTemp
Loop
Investor.Txt would then be changed to:
INVESTOR A
INVESTOR B
INVESTOR C
[EOF]
-
I've emulated the error, from what i expected to be the problem, that is, you have a function that is named eof somewhere,
Code:
Private Sub Form_Load()
Open "C:\windows\desktop\test" For Binary As #1
Debug.Print eof(1)
Close #1
End Sub
Function eof(a())
End Function
either change the name of your eof function or change the end of file call to
and it will work just fine :)
-
Kedaman,
It worked! You made my day. Thanks!!!!
Madi