Results 1 to 3 of 3

Thread: A Set Number Of Lines In Text File

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Posts
    14

    Post

    I need to find a way to add a file to the top of a text file that is going to be a list of files recently used documents. Or a way to read the file from the bottom to the top.

    [This message has been edited by Eric M (edited 01-28-2000).]

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Post

    Hi Eric M.

    I believe that this code does what you are looking for.
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
        Dim stFiles() As String
        Dim iCounter As Integer
        
        'Read the current file into an array
        Open "C:\YourTextFile.txt" For Input As #1
        
        Do Until EOF(1)
            ReDim Preserve stFiles(iCounter)
            Input #1, stFiles(iCounter)
            iCounter = iCounter + 1
        Loop
        
        Close #1
        
        'Put the new file name at the top of the text file
        Open "C:\YourTextFile.txt" For Output As #1
        
        Write #1, "New File Name"
        For iCounter = 0 To UBound(stFiles)
            Write #1, stFiles(iCounter)
        Next iCounter
        
        Close #1
    End Sub
    All the best.

    ------------------
    OneSource
    The truth may be out there, but it's in here too!
    .


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

  3. #3
    Lively Member
    Join Date
    Jan 1999
    Location
    Burlington, IA, USA`
    Posts
    77

    Post

    You could use the registry instead of a text file to save a recent file list.

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