|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Open a text file and into an array ??Can someoneillustrate how I would open a text file that looks something
similar to this: namea,8888,1234.99 nameb,8887,1242.50 and then after opening that file read each one of the values into an array...namea and 8888 and 1234.99 would be three arrays thanks Jason wrote:
>Can someoneillustrate how I would open a text file that looks something Actually, it would be one array, with three indeces.>similar to this: >namea,8888,1234.99 >nameb,8887,1242.50 > >and then after opening that file read each one of the values into an >array...namea and 8888 and 1234.99 would be three arrays > >thanks > > > > dim sline as string = lineinput(filepointer) dim aline as array = split(sline,",") Then you would have these values: aline(0) = namea aline(1) = 8888 aline(2) = 1234.99 Tom "tomb" <t***@technetcenter.com> wrote in message news:NJOHf.7955$bW.1670@bignews8.bellsouth.net... Jason wrote:Can someoneillustrate how I would open a text file that looks something similar to this: namea,8888,1234.99 nameb,8887,1242.50 and then after opening that file read each one of the values into an array...namea and 8888 and 1234.99 would be three arrays thanks Actually, it would be one array, with three indeces. dim sline as string = lineinput(filepointer) dim aline as array = split(sline,",") Then you would have these values: aline(0) = namea aline(1) = 8888 aline(2) = 1234.99 Tom How would I actually open the file?....and then get that file to seperate into the array. Lets say the file name is test.txt for example I want to store namea as strUser 8888 as dblaccess and 1234.99 as dblaccount so I would like it to fill an array like this... info(0).strUser = "namea" info(0).dblaccess = 8888 info(0).dblaccount = 1234.99 and info(1).strUser = "nameb" info(1).dblaccess = 8887 info(1).dblaccount = 1242.50 and so on until the end of file. Jason wrote:
Show quoteHide quote > Why do you need it in an array? > > "tomb" <t***@technetcenter.com <mailto:t***@technetcenter.com>> > wrote in message news:NJOHf.7955$bW.1670@bignews8.bellsouth.net... > Jason wrote: > >>Can someoneillustrate how I would open a text file that looks something >>similar to this: >>namea,8888,1234.99 >>nameb,8887,1242.50 >> >>and then after opening that file read each one of the values into an >>array...namea and 8888 and 1234.99 would be three arrays >> >>thanks >> >> >> >> > Actually, it would be one array, with three indeces. > > dim sline as string = lineinput(filepointer) > dim aline as array = split(sline,",") > Then you would have these values: > aline(0) = namea > aline(1) = 8888 > aline(2) = 1234.99 > > Tom > > How would I actually open the file?....and then get that file to > seperate into the array. Lets say the file name is test.txt > > for example I want to store namea as strUser 8888 as dblaccess > and 1234.99 as dblaccount > > so I would like it to fill an array like this... > info(0).strUser = "namea" > info(0).dblaccess = 8888 > info(0).dblaccount = 1234.99 > > and > info(1).strUser = "nameb" > info(1).dblaccess = 8887 > info(1).dblaccount = 1242.50 > > and so on until the end of file. > I ask only because in order to dimension the array at the start, you would need to know how many lines of data you have. While you could keep redimensioning the array with every line you read, that would be a serious resource hog. You might want to consider putting the data in a datatable and working with it that way. Or just read and process one line at a time, as my original illustration would do. T
VB.NET or C#.NET ???
Is there a difference between passing "" and passing Nothing to a Windows API ? Moving a project from 2003 to 2005 Time? UI Design question 2003 0r 2005 Using GetOleDbSchemaTable and Visual Basic .NET for MS-Access and SQL Server Express TCP/IP Socket communication from multiple clients reading text files Help to Italy |
|||||||||||||||||||||||