Visual Basic: MSFlexGrid/MSHFlexGrid Controls

TextArray Property Example

The following example shows how to calculate cellindex by defining a function.

Note   If you are using the MSFlexGrid, substitute "MSHFlexGrid1" with "MSFlexGrid1."

  ' Calculate index for use with TextArray property.
Function faIndex(row As Integer, col As Integer) As Long
faIndex =row * MSHFlexGrid1.Cols + col
End Function
Sub Form_Load()
Dim i as Integer
' Fill MSHFlexGrid with data using TextArray property.
For i =MSHFlexGrid1.FixedRows to MSFlexGrid1.Rows - 1
' ** column 1
MSHFlexGrid1.TextArray(faIndex(i, 1)) =RandomName()
' Column 2.
MSHFlexGrid1.TextArray(faIndex(i, 2)) =RandomNumber()
Next