home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frmControlArray
- Caption = "Control Array Example"
- Height = 6840
- Left = 1020
- LinkTopic = "Form1"
- ScaleHeight = 6435
- ScaleWidth = 6075
- Top = 270
- Width = 6195
- Begin CommandButton cmdClose
- Caption = "&Close"
- Height = 495
- Left = 3960
- TabIndex = 5
- Top = 4440
- Width = 1215
- End
- Begin PictureBox picDisplay
- Height = 1215
- Left = 600
- ScaleHeight = 1185
- ScaleWidth = 4905
- TabIndex = 4
- Top = 360
- Width = 4935
- End
- Begin CommandButton cmdDelete
- Caption = "&Delete"
- Height = 495
- Left = 3960
- TabIndex = 3
- Top = 3120
- Width = 1215
- End
- Begin CommandButton cmdAdd
- Caption = "&Add"
- Height = 495
- Left = 3960
- TabIndex = 2
- Top = 2355
- Width = 1215
- End
- Begin OptionButton optButton
- Caption = "Option2"
- Height = 495
- Index = 1
- Left = 960
- TabIndex = 1
- Top = 2640
- Width = 1215
- End
- Begin OptionButton optButton
- Caption = "Option1"
- Height = 495
- Index = 0
- Left = 960
- TabIndex = 0
- Top = 2235
- Width = 1215
- End
- Begin Label lblColor
- Caption = "Select an option button to display a new color."
- Height = 495
- Left = 600
- TabIndex = 6
- Top = 1800
- Width = 3015
- End
- Dim MaxId As Integer
- Sub cmdAdd_Click ()
- If MaxId = 0 Then MaxId = 1 ' Set total option buttons.
- If MaxId > 8 Then Exit Sub ' Only ten buttons allowed.
- MaxId = MaxId + 1 ' Increment button count.
- Load OptButton(MaxId) ' Create new button.
- OptButton(0).SetFocus ' Reset button selection.
- ' Set new button under previous button.
- OptButton(MaxId).Top = OptButton(MaxId - 1).Top + 400
- OptButton(MaxId).Visible = True ' Display new button.
- OptButton(MaxId).Caption = "Option" & MaxId + 1
- End Sub
- Sub cmdClose_Click ()
- Unload Me ' Unload this form.
- End Sub
- Sub cmdDelete_Click ()
- If MaxId = 1 Then Exit Sub ' Keep first two buttons.
- Unload OptButton(MaxId) ' Delete last button.
- MaxId = MaxId - 1 ' Decrement button count.
- OptButton(0).SetFocus ' Reset button selection.
- End Sub
- Sub optButton_Click (Index As Integer)
- ' Index indicates the control in the control array that was clicked.
- picDisplay.BackColor = QBColor(Index + 1)
- End Sub
-