|
Thread: EOF
-
Nov 2nd, 2000, 11:37 AM
#1
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
-
Nov 2nd, 2000, 11:51 AM
#2
Fanatic Member
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
Gary Lowe 
VB6 (Enterprise) SP5
ADO 2.6
SQL Server 7 SP3
OK I know my spelling and grammer is crap so don't quote me on it!
To err is human to take the P! is only natural !!
Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip

-
Nov 2nd, 2000, 11:53 AM
#3
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.
-
Nov 2nd, 2000, 12:12 PM
#4
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]
-
Nov 2nd, 2000, 12:20 PM
#5
transcendental analytic
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
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 2nd, 2000, 12:31 PM
#6
Kedaman,
It worked! You made my day. Thanks!!!!
Madi
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|