> I want to load comma sep text files and display it in a grid. I'd like
something simple and lightweight. Don't need to edit it in grid, I
could do that in textboxes if required.
If you use an MSFlexGrid control, you can load your CSV text files via
the Clip property (which requires you to select enough cells to house
all the data... for what you want, simply select the entire grid). Place
a MSFlexGrid on your form and give this code a try...
Rick - MVP
Dim FileNum As Integer
Dim TotalFile As String
FileNum = FreeFile
' Reads the entire file into memory all at once
Open "c:\SomeDirecto ry\TextFile.txt " For Binary As #FileNum
TotalFile = Space(LOF(FileN um))
Get #FileNum, , TotalFile
Close #FileNum
TotalFile = Replace(Replace (TotalFile, vbNewLine, vbCr), ",", vbTab)
With MSFlexGrid1
' Assuming user can't select a cell
' .HighLight = flexHighlightNe ver
' Select every cell
.Row = .FixedRows
.Col = .FixedCols
.RowSel = .Rows - 1
.ColSel = .Cols - 1
' Fill them
.Clip = TotalFile
' Get rid of selection and pick cell to be active
.Row = 1
.Col = 1
End With