Results 1 to 3 of 3

Thread: Read From TextFile

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Location
    Malaysia
    Posts
    2

    Post

    Hi everybody,
    do you guys know how to use VB6 to read certain amount of characters from a textfile with a lot of characters in single line ? for example: a text file with 10,000 characters in single line and I want to get the first 1,000 characters only. if this way can be done in VB6 that could you please show me how to get subsequent characters in 1,000 character per read.
    thanks.

  2. #2
    Guest

    Post

    Open the file binary, preallocate a string and loop until you reach the end.

    Code:
        Dim iFileNummer As Integer
        Dim lPos As Long
        Dim sInput As String
        Dim sTotal As String
        
        iFileNummer = FreeFile
        Open "C:\MyLargeFile" For Binary As #iFileNummer
        For lPos = 1 To LOF(iFileNummer) Step 1000
            sInput = Space(1000)
            Get #iFileNummer, lPos, sInput
            sTotal = sTotal & sInput
        Next
        Close #iFileNummer
    Hope it helps.

    ------------------

    Vincent van den Braken
    EMail: [email protected]
    ICQ: 15440110
    Homepage: http://www.azzmodan.demon.nl




  3. #3
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Post

    hi!
    In C you can assign a length to a string. If you can do that somehow in vb, then you could set the length to 1,000 and then get that var from the text file. I've never tried this, but maybe it works.

    Regards,
    Alexander McAndrew
    VB Zone http://gsenterprise.server101.com

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