Results 1 to 2 of 2

Thread: Freefile

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    BC
    Posts
    11

    Post

    I am using freefile and I have read the four first lines of data in my .txt and then made it stop.Now if I press Cammand1_Click() again I want it to read the next four lines.
    Could anyone help?

    Thanks
    Coco

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

    Post

    Hi Coco,

    Here's how to do it.

    Create a VB project with a big Textbox and a Command Button. For the Textbox, set the Multiline property to True and give it a Vertical Scroll Bar.

    Put this code in the VB Editor:

    Change "c:\bootlog2.txt" to indicate the path and name of your file.
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
        Dim lFileNum As Long
        Dim stTemp() As String
        Static iCounter As Integer
        Dim iFourlines As Integer
        Dim iLoop As Integer
        Dim stHold As String
        Dim iPreviousCount As Integer
        
        lFileNum = FreeFile
        
        Open "c:\bootlog2.txt" For Input As lFileNum
        
        Do Until iPreviousCount = iCounter
            Line Input #lFileNum, stHold
            iPreviousCount = iPreviousCount + 1
        Loop
        
        Do Until iFourlines = 4 Or EOF(lFileNum)
            ReDim Preserve stTemp(iFourlines)
            Line Input #lFileNum, stTemp(iFourlines)
            iCounter = iCounter + 1
            iFourlines = iFourlines + 1
        Loop
        
        For iLoop = 0 To (iFourlines - 1)
            Text1 = Text1 & stTemp(iLoop) & vbCrLf
        Next
        
        Text1.SelStart = Len(Text1)
        Text1.SetFocus
        Close lFileNum
    End Sub
    
    Private Sub Form_Load()
        Text1 = ""
    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 02-09-2000).]

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