0

So I need to put all the names in a file into column 1 on flexgird, each name should go on its own row. here is what I have but i just get "invalid row value"

namefile = App.Path & "\names.dat"
Open namefile For Input As #1
While Not EOF(1)
    Input #1, x
        With MSFlexGrid1
            .Col = 1
            .Rows = rowcount + 1
            .Text = x
        End With
Wend
End Sub

Any help would be fantastic and thanks in advance

Andeeh
  • 99
  • 1
  • 4
  • 12
  • You don't appear to be setting .Row (the current row). This probably should be set to .Rows - 1. Also, you could use .TextMatrix (I believe this gives better performance). – Paul Michaels Apr 05 '10 at 15:45

2 Answers2

1

I'm not sure why rowcount is in your example code, but this works for me

namefile = App.Path & "\names.dat"
Open namefile For Input As #1
MSFlexGrid1.Rows = 1
MSFlexGrid1.Col = 1
While Not EOF(1)
    Input #1, x
    With MSFlexGrid1
       .Rows = .Rows + 1
       .Row = .Rows - 1
       .Text = x
    End With
Wend
End Sub

I've also pulled the .Col =1 out of your loop - you don't need to keep setting it and your loop will be faster than without it (not by much but repeatedly setting it is pointless)

CResults
  • 5,100
  • 1
  • 22
  • 28
0

How to dump contents of the Recordset into a Flexgrid.

Once you load whatever it is into a recordset, this article provides techniques on various things you'll want to do with the grid.

AngryHacker
  • 59,598
  • 102
  • 325
  • 594