CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2013
    Posts
    1

    Question add columns from outside string into text file

    hi guys.
    I'm new in VB and I have some text file (F:\path\Boeing747\Lufthansa.txt) consist of data as below:

    2013-03-01 00:05:01|Florence
    2013-03-01 00:20:01|Tokyo
    2013-03-01 00:35:01|Oslo
    2013-03-01 00:40:01|Los Angeles

    is there any code that I can use to add more columns so that the data would be looked like below:

    2013-03-01 00:05:01|Lufthansa|Boeing747|Florence
    2013-03-01 00:20:01|Lufthansa|Boeing747|Tokyo
    2013-03-01 00:35:01|Lufthansa|Boeing747|Oslo
    2013-03-01 00:40:01|Lufthansa|Boeing747|Los Angeles

    kindly need your advice.
    thank's

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: add columns from outside string into text file

    You would need to read the file into your program, probably one line at a time using the Line Input # method then make changes to the data from that line and then write it out to a new file using the Print # method. You would do this in a loop to process every line then once you are done close the files and if desired use Kill to delete the original file and Name to rename the new file.
    Always use [code][/code] tags when posting code.

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

Featured