|
-
Aug 4th, 2005, 03:28 PM
#11
Hyperactive Member
Re: Loading Into an MSFlexGrid
Does your flexgrid have enough rows? If not use .additem to add rows. You could amend dglienna's code if you want to:
 Originally Posted by dglienna
VB Code:
Public Function ReadFlex(FileName As String)
Dim str As String, rowI() As String, colI() As String
Open FileName For Input As #1
str = Input(LOF(1), #1) ' Read file into string
[COLOR=DarkRed][I] str = replace(str,",",vbTab) ' replaces comma with a tab character, so .additem works properly[/I][/COLOR]
Close #1 'Close the file
rowI() = Split(str, vbCrLf) ' Split into rows
[COLOR=DarkRed][I]for z= MSFlexgrid1.rows to 1 step -1
MSFlexgrid1.removeitem 1
next z[/I][/COLOR]
For i = 0 To UBound(rowI) ' Determine number of rows
[COLOR=DarkRed][I]MSFlexgrid1.additem rowI(i)[/I][/COLOR]
Next i
End Function
.additem will add a row, and uses the tab character to split the input row into columns. My approach deletes all the rows in the grid first, then populates it one row at a time
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|