AddItem, RemoveItem Methods (MSHFlexGrid) Example

This example uses the AddItem method to add 100 items to an MSHFlexGrid. To use this example, paste the code into the Declarations section of a form with an MSHFlexGrid named MSHFlexGrid1, press f5, and then click the form.

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

Private Sub Form_Click ()
   Dim Entry, i, Msg               ' Declare variables.
   Msg =_
   "Choose OK to add 100 items to your MSHFlexGrid."
   MsgBox Msg   ' Display message.
   MSHFlexGrid1.Cols =2         ' Two strings per row.
   For i =1 To 100   ' Count from 1 to 100.
      Entry ="Entry " & Chr(9) & I   ' Create entry.
      MSHFlexGrid1.AddItem Entry      ' Add entry.
   Next i
   Msg ="Choose OK to remove every other entry."
   MsgBox Msg                     ' Display message.
   For i =1 To 50               ' Determine how to
      MSHFlexGrid1.RemoveItem i   ' remove every other
   Next I                        ' item.
   Msg ="Choose OK to clear all items."
   MsgBox Msg                     ' Display message.
   MSHFlexGrid1.Clear               ' Clear list box.
End Sub