reading and opening textfile.. Need help...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rizzie
    New Member
    • Nov 2007
    • 10

    reading and opening textfile.. Need help...

    Hi,

    I am trying to access a text file in vb6, well I have accessed it but it gives me per line result. I need the exact character given a specific position. Is there any way to access the file and return values per character???

    Thanks in advance =)
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by rizzie
    I am trying to access a text file in vb6, well I have accessed it but it gives me per line result. I need the exact character given a specific position. Is there any way to access the file and return values per character?
    Yes. Open the file For Binary rather than For Input. Then use the Get statement to read from it. You can specify the location to read, or it will just continue from where it's up to. The size of the variable you read the data into will determine how much it reads. So if you define a variable as String * 1 for example, you can read one byte at a time.

    Comment

    • lotus18
      Contributor
      • Nov 2007
      • 865

      #3
      Hi there

      Click this link click me. Hope you can get your answer here.

      Rey Sean

      Comment

      • rizzie
        New Member
        • Nov 2007
        • 10

        #4
        Originally posted by Killer42
        Yes. Open the file For Binary rather than For Input. Then use the Get statement to read from it. You can specify the location to read, or it will just continue from where it's up to. The size of the variable you read the data into will determine how much it reads. So if you define a variable as String * 1 for example, you can read one byte at a time.
        Thanks for the quick response... But I do have additional questions.. Can I use Binary File Access given a specific line. To explain it further here is the scenario:

        I have this text file...
        H5J0001T20071127 -2 0
        1BAGICN21015000 150631901015001 50
        SBAGICN01
        2 Y 015000000000000 000000000000000 00
        4 Y00000000000000 000000000000000 00011
        H5J0001T20071129 000C0
        1BAGICN41015000 150631901015001 50
        SBAGICN01

        I need to read the line with H as the first character. With that specific line I need to extract the data by reading the character with a given position..
        I really appreciate your help... again thank you...

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Oops. Forget binary mode.

          Just read line by line, and use the Left() and/or Mid() functions to pull the desired characters out of the text.

          Comment

          • rizzie
            New Member
            • Nov 2007
            • 10

            #6
            Originally posted by Killer42
            Oops. Forget binary mode.

            Just read line by line, and use the Left() and/or Mid() functions to pull the desired characters out of the text.
            Ahhh.. yeah. How come I didn't think of that solution? Hehehehe. Thanks for the help...=)
            Last edited by Killer42; Dec 19 '07, 04:00 AM.

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by rizzie
              Ahhh.. yeah. How come I didn't think of that solution? Hehehehe. Thanks for the help...=)
              Give it a couple of years - experience makes the difference.

              We're always glad to help around here. :)

              Comment

              Working...