questrel
asked on
Loading a textfile into MSFlexGrid (VB6)
Hi,
I am very new to the use of MSFlexGrid
I have saved the data in my flexgrid to a csv file using the code below
That part is working fine.
I am having some trouble loading the file back into flexgrid after though. I am using the code below and it isn't working
I would appreciate if someone could show me the error of my ways.
I am very new to the use of MSFlexGrid
I have saved the data in my flexgrid to a csv file using the code below
For iRow = 0 To 49
For iCol = 0 To 49
Write #iFileHandle, MSFlexGrid1.TextMatrix(iRow, iCol);
Next iCol
Write #iFileHandle,
Next iRow
That part is working fine.
I am having some trouble loading the file back into flexgrid after though. I am using the code below and it isn't working
For iRow = 0 To 49
For iCol = 0 To 49
Line Input #iFileHandle, sLineIn
MSFlexGrid1.TextMatrix(iRow, iCol) = Split(sLineIn, ",")
Next iCol
Next iRow
I would appreciate if someone could show me the error of my ways.
try using the Read statement. It is the opposite of the Write statement.
ASKER
That didnt work unfortunately.
Perhaps i need to read the file into an array?
Perhaps i need to read the file into an array?
what do you see in the flexgrid?
My expectation is that you will see an empty cell in each row, starting with the second row. If that is the case, then you should remove the additional Write statement at the end of each row.
My expectation is that you will see an empty cell in each row, starting with the second row. If that is the case, then you should remove the additional Write statement at the end of each row.
Write #iFileHandle,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Ark. That has helped me to read in the data
Here is the code which works for me
OpenFile
SaveFile
Here is the code which works for me
OpenFile
For iRow = 0 To 49
Line Input #iFileHandle, sLineIn
Dim values() As String
values = Split(sLineIn, ",")
For iCol = 0 To 49
If UBound(values) >= iCol Then
MSFlexGrid1.TextMatrix(iRow, iCol) = values(iCol)
End If
Next iCol
Next iRow
SaveFile
For iRow = 0 To 49
For iCol = 0 To 49
Write #iFileHandle, MSFlexGrid1.TextMatrix(iRow, iCol);
Next iCol
Write #iFileHandle,
Next iRow