Computing.Net > Forums > Programming > read txt/ create array

read txt/ create array

Reply to Message Icon

Original Message
Name: johnbeer
Date: December 22, 2003 at 05:47:29 Pacific
Subject: read txt/ create array
OS: vb 6
CPU/Ram: 224
Comment:

Hi there,
I want to count the amount of lines in a txt file,then create an array(based on the amount of lines) then read the numbers from that txt file into created array.(amount of numbers in txt might change every time)
I do not work with vb on daily basis, and can not get it to work.
thanks


Report Offensive Message For Removal

Response Number 1
Name: lindsey802407
Date: December 22, 2003 at 09:58:11 Pacific
Subject: read txt/ create array
Reply: (edit)

Check ur email! I sent you a similar C++ program.


Report Offensive Follow Up For Removal

Response Number 2
Name: FishMonger
Date: December 22, 2003 at 12:53:51 Pacific
Subject: read txt/ create array
Reply: (edit)

johnbeer,
Are you required to use VB, or can you use a language that's better suited for this. Depending on the exact format of the txt file and what you need to do with the array, this is only 1 to 5 lines of Perl code.

examples:
This will readin entire the file into an array.

@lines = <>;

This will print out the number of elements in the array.

print $#array;

This will readin the file line by line, and build an array of numbers that it finds.

while (<>) {(push @array, $1) while ($_ =~ /(\d+)/g);}


lindsey,
Since this is an open forum, it's recommended and better forum etiquette to post your solutions rather than emailing.


Report Offensive Follow Up For Removal

Response Number 3
Name: johnbeer
Date: December 23, 2003 at 00:25:37 Pacific
Subject: read txt/ create array
Reply: (edit)

I have to use VB!! But perl code looks much shorter for the same kind of job.

Thanks for the advise,


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: read txt/ create array

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software