Visual Basic Reference

Shape Property Example

This example illustrates the six possible shapes of the Shape control. To try this example, paste the code into the Declarations section of a form that contains an OptionButton control and a Shape control. For the OptionButton, set the Index property to 0 to create a control array of one element, and then press F5. Click each OptionButton to see each different shape.

  Private Sub Form_Load ()
   Dim I   ' Declare variable.
   Option1(0).Caption = "Shape #0"
   For I = 1 To 5    ' Create five instances of Option1.
      Load Option1(I)
      ' Set the location of the new option button.
      Option1(I).Top = Option1(I - 1).Top + Option1(0).Height + 40
      ' Set the option button caption.
      Option1(I).Caption = "Shape #" & I
      ' Display the new option button.
      Option1(I).Visible = True
   Next I
End Sub

Private Sub Option1_Click (Index As Integer)
 Shape1.Shape = Index
End Sub