Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004
    Posts
    285
    Provided Answers: 1

    Unanswered: OpenAsTextStream length limitations

    Good day,

    I have a rather large txt flat file with data in it that is created and sent to me. Unfortunately the file is one very long text stream. I use the OpenAsTextStream to read the line into a variable and then cut this varible up into the parts I need. The problem I have suddenly noticed is that not all the characters get passed to the variable. For some reason after a while the text stream is empty? Why is this, is there some sort of length of characters that the stream can read?

    Please help

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Quote Originally Posted by plsh
    Good day,

    I have a rather large txt flat file with data in it that is created and sent to me. Unfortunately the file is one very long text stream. I use the OpenAsTextStream to read the line into a variable and then cut this varible up into the parts I need. The problem I have suddenly noticed is that not all the characters get passed to the variable. For some reason after a while the text stream is empty? Why is this, is there some sort of length of characters that the stream can read?

    Please help
    I'm not aware of any length limitations. Are you using classic VB (5/6) or VB.Net?
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    Nov 2004
    Posts
    285
    Provided Answers: 1
    The file is a few hundred thousand characters in length. Initially the file was loaded using DTS in SQL Server 2000 and I have tested using VB6. What the problem is I have now noticed is that when the characters are loaded into the variable the last about third of the characters are all replaced with blanks which clearly makes the data useless.
    Is there another way I can load this loooooong string of characters. As I said I have to do some manipulation to it and have no control over the file created.

  4. #4
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    You could use VB's native File I/O. Load the file into a single string, and process the resultant string.

    Code:
    Dim ff as Integer
    Dim FileText as String
    Dim FileData() as String
    Dim N as Long
    
    ff = FreeFile
    
    Open "YourTextFilePath.txt" For Binary as #ff
      FileText = Space(LOF(ff))
      Get #ff,,FileText
    
      ' break up the single string to the array of string
      FileData = Split(FileText, vbnewline)
    Close #ff
    
    For N = LBound(FileData) to UBound(FileData)
      ' replace the line below with your processing
      Debug.Print FileData(N)
    Ref this File I/O Tutorial at a sister-site.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •