Reading Text Files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nimesh2008
    New Member
    • Oct 2007
    • 1

    Reading Text Files

    Please can anybody solve this dilemma? It's very urgent.
    How to read the following text file and assign col5 as integer and get the values which are less than -500 and more than 500 but not equal to 0 in new text file by vb6.0?
    col1|col2|col3| col4|col5|col6|
    AXC
    doc|100|500|780 0|900|chd|no5|
    MNC
    doc|100|500|680 0|200|chd|no6|

    Get output in below format

    doc|200| or doc,200,
    Last edited by Killer42; Oct 18 '07, 10:29 PM.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Originally posted by Nimesh2008
    get the values which are less than -500 and more less than 500 but not equal to 0
    What do you mean by this ?

    Post your question clearly.

    Comment

    • cugone
      New Member
      • Sep 2007
      • 20

      #3
      What version of VB? 6.0, 2003, or 2005?

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Originally posted by cugone
        What version of VB? 6.0, 2003, or 2005?
        Hi Cugone,

        Read the post properly, he has already mentioned VB 6.0


        Regards
        Veena

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by Nimesh2008
          ... How to read the following text file and assign col5 as integer and get the values which are less than -500 and more than 500 but not equal to 0 in new text file by vb6.0?
          Ok, two things. First, use the Split() function to chop up the text on the "|" delimiters.
          Second, your logic is a bit fuzzy there. A number which is less than -500 or more than 500 cannot possibly equal zero.

          So the code will be quite simple:
          • Open the file for reading
          • Read each line
          • Use Split() to chop it into an array
          • Check the fifth entry (number 4, since they start at 0) in the array
          • If < -500 or > 500 then write it to new file.
          • End of loop.

          Comment

          Working...