Click to See Complete Forum and Search --> : Please Help - Populating a grid with a tab delimited file...


rlecjr
March 26th, 2001, 01:31 PM
I have to write VB functionality to read in a tab-delimited file and write the data to a cross-tabular grid. For example, the following data comes in the file "Name<tab>Class<tab>Grade". The name of each student would be in the left column, the class would be across the top row and the grades would be listed at their intersecting points.

So, I guess this is a 2-part question. (1) How do I read in the file so that it recognizes that it is tab-delimited? (2)Which grid control can I use to load the data in the manner that I suggested?

I am EXTREMELY greatful for any help that anyone can provide!!!

Thanks,
Ron

Iouri
March 26th, 2001, 02:19 PM
(1) How do I read in the file so that it recognizes that it is tab-delimited?

dim line() as string

Open "c:\YourFile.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, csvline
'This will split the line at the tab and put each element in the line() array.
line=split(csvline,vbTab)
'now do some calculation and put it into your grid
Loop
Close #1


(2)Which grid control can I use to load the data in the manner that I suggested?
It is a matter of preferances. I prefer MSFlexGrid




Iouri Boutchkine
iouri@hotsheet.com

rlecjr
March 26th, 2001, 02:23 PM
Thanks Iouri -

Before I venture into the MSFlexGrid, is it possible to create a crosstab using this type of grid? ie. As per my example, I would need to have column headers and row headers and then data displayed at the intersecting points....

rlecjr
March 26th, 2001, 03:33 PM
....