Results 1 to 6 of 6

Thread: EOF

  1. #1
    Guest

    Exclamation

    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


  2. #2
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621
    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


  3. #3

  4. #4
    Guest
    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]



  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Code:
    filesystem.EOF(1)
    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.

  6. #6
    Guest

    Smile

    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
  •  



Click Here to Expand Forum to Full Width