Results 1 to 2 of 2

Thread: Input from File

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 1999
    Location
    Karlsruhe, Germany
    Posts
    122

    Post

    Check out this:

    Code:
    Dim Count1 As Long
    Dim FileName As String
    Dim FileHandle As Long
    
    FileName = "C:\temp\test.txt"
    FileHandle = FreeFile   'Use this instead of a fixed number!
    Open FileName For Random As #FileHandle Len = 15
    
    'EOF gives back False (0) as long as
    'your not at the enf of file!
    Count1 = 0
    Do While Not EOF(FileHandle)
        Count1 = Count1 + 1
        'Rest of processing...
    Loop
    
    Close #FileHandle
    Hope it helps
    Roger

    [This message has been edited by RogerH (edited 01-01-2000).]

  2. #2
    Lively Member
    Join Date
    Sep 1999
    Location
    Huntsville, AR 72740, USA
    Posts
    90

    Post

    Private Sub Form Load()
    Dim Count1 as Integer
    Dim Count2 as Integer

    [Other Preps deleted]

    FileName = App.Path & "\MArt.txt"
    Open FileName for Random as #1 Len = 153
    For Count1 = 1 to EOF(1)
    '[STOPS]
    Get #1, Count1, FVars
    'FVars is a fixed length string variable
    Count2 = Count2 + 1
    Next Count1
    If Count2 < 0 Then

    [Deleted]

    End If
    If Count2 > 0 Then
    ReDim MArti(23, Count2)
    For Count1 = 1 to EOF(1)
    Get #1, Count1, FVars
    'Break FVars down into Fixed length variable with Mid$
    'Move From Variable into MArti Array
    Next Count1
    Close
    End Sub

    This section is designed to open a file, read in a bunch of information and then allow the user to manupliate the info. Simple and straightforwards.
    However, regardless of whether there is any info in the file or not the program always [STOPS] as though it receives EOF(1).
    The save routine saves the information upon exiting the program, and works perfectly, as far as I can tell. Even after open up the file with a another text reader, everything seems to be in order.
    Anyone have any ideas whats going on?


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