home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmControlArray
- Caption = "Control Array Example"
- ClientHeight = 6420
- ClientLeft = 675
- ClientTop = 1440
- ClientWidth = 6090
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 1
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 6825
- Left = 615
- LinkTopic = "Form1"
- ScaleHeight = 6420
- ScaleWidth = 6090
- Top = 1095
- Width = 6210
- Begin VB.OptionButton optButton
- Caption = "Option2"
- Height = 330
- Index = 1
- Left = 735
- TabIndex = 6
- Top = 2835
- Width = 2010
- End
- Begin VB.OptionButton optButton
- Caption = "Option1"
- Height = 330
- Index = 0
- Left = 735
- TabIndex = 5
- Top = 2415
- Width = 2010
- End
- Begin VB.CommandButton cmdClose
- Caption = "&Close"
- Height = 495
- Left = 3960
- TabIndex = 3
- Top = 4440
- Width = 1215
- End
- Begin VB.PictureBox picDisplay
- Height = 1215
- Left = 630
- ScaleHeight = 1185
- ScaleWidth = 4905
- TabIndex = 2
- Top = 360
- Width = 4935
- End
- Begin VB.CommandButton cmdDelete
- Caption = "&Delete"
- Height = 495
- Left = 3960
- TabIndex = 1
- Top = 3120
- Width = 1215
- End
- Begin VB.CommandButton cmdAdd
- Caption = "&Add"
- Height = 495
- Left = 3960
- TabIndex = 0
- Top = 2355
- Width = 1215
- End
- Begin VB.Label lblColor
- Caption = "Select an option button to display a new color."
- Height = 495
- Left = 600
- TabIndex = 4
- Top = 1800
- Width = 3015
- End
- Attribute VB_Name = "frmControlArray"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Dim MaxId As Integer
- Private Sub cmdAdd_Click()
- If MaxId = 0 Then MaxId = 1 ' Set total option buttons.
- If MaxId > 8 Then Exit Sub ' Only ten buttons are allowed.
- MaxId = MaxId + 1 ' Increment the button count.
- Load OptButton(MaxId) ' Create a new button.
- OptButton(0).SetFocus ' Reset the button selection.
- ' Place the new button below the previous button.
- OptButton(MaxId).Top = OptButton(MaxId - 1).Top + 400
- OptButton(MaxId).Visible = True ' Display the new button.
- OptButton(MaxId).Caption = "Option" & MaxId + 1
- End Sub
- Private Sub cmdClose_Click()
- Unload Me ' Unload this form.
- End Sub
- Private Sub cmdDelete_Click()
- If MaxId <= 1 Then Exit Sub ' Keep the first two buttons.
- Unload OptButton(MaxId) ' Delete the last button.
- MaxId = MaxId - 1 ' Decrement the button count.
- OptButton(0).SetFocus ' Reset the button selection.
- End Sub
- Private Sub optButton_Click(Index As Integer)
- ' Index indicates the control that was clicked in the control array.
- picDisplay.BackColor = QBColor(Index + 1)
- End Sub
-