home *** CD-ROM | disk | FTP | other *** search
/ Master 95 #1 / MASTER95_1.iso / microsof / vbasic4 / vb4-6.cab / array.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-26  |  3.7 KB  |  111 lines

  1. VERSION 4.00
  2. Begin VB.Form frmControlArray 
  3.    Caption         =   "Control Array Example"
  4.    ClientHeight    =   6420
  5.    ClientLeft      =   675
  6.    ClientTop       =   1440
  7.    ClientWidth     =   6090
  8.    BeginProperty Font 
  9.       name            =   "MS Sans Serif"
  10.       charset         =   1
  11.       weight          =   700
  12.       size            =   8.25
  13.       underline       =   0   'False
  14.       italic          =   0   'False
  15.       strikethrough   =   0   'False
  16.    EndProperty
  17.    Height          =   6825
  18.    Left            =   615
  19.    LinkTopic       =   "Form1"
  20.    ScaleHeight     =   6420
  21.    ScaleWidth      =   6090
  22.    Top             =   1095
  23.    Width           =   6210
  24.    Begin VB.OptionButton optButton 
  25.       Caption         =   "Option2"
  26.       Height          =   330
  27.       Index           =   1
  28.       Left            =   735
  29.       TabIndex        =   6
  30.       Top             =   2835
  31.       Width           =   2010
  32.    End
  33.    Begin VB.OptionButton optButton 
  34.       Caption         =   "Option1"
  35.       Height          =   330
  36.       Index           =   0
  37.       Left            =   735
  38.       TabIndex        =   5
  39.       Top             =   2415
  40.       Width           =   2010
  41.    End
  42.    Begin VB.CommandButton cmdClose 
  43.       Caption         =   "&Close"
  44.       Height          =   495
  45.       Left            =   3960
  46.       TabIndex        =   3
  47.       Top             =   4440
  48.       Width           =   1215
  49.    End
  50.    Begin VB.PictureBox picDisplay 
  51.       Height          =   1215
  52.       Left            =   630
  53.       ScaleHeight     =   1185
  54.       ScaleWidth      =   4905
  55.       TabIndex        =   2
  56.       Top             =   360
  57.       Width           =   4935
  58.    End
  59.    Begin VB.CommandButton cmdDelete 
  60.       Caption         =   "&Delete"
  61.       Height          =   495
  62.       Left            =   3960
  63.       TabIndex        =   1
  64.       Top             =   3120
  65.       Width           =   1215
  66.    End
  67.    Begin VB.CommandButton cmdAdd 
  68.       Caption         =   "&Add"
  69.       Height          =   495
  70.       Left            =   3960
  71.       TabIndex        =   0
  72.       Top             =   2355
  73.       Width           =   1215
  74.    End
  75.    Begin VB.Label lblColor 
  76.       Caption         =   "Select an option button to display a new color."
  77.       Height          =   495
  78.       Left            =   600
  79.       TabIndex        =   4
  80.       Top             =   1800
  81.       Width           =   3015
  82.    End
  83. Attribute VB_Name = "frmControlArray"
  84. Attribute VB_Creatable = False
  85. Attribute VB_Exposed = False
  86. Dim MaxId As Integer
  87. Private Sub cmdAdd_Click()
  88.     If MaxId = 0 Then MaxId = 1         ' Set total option buttons.
  89.     If MaxId > 8 Then Exit Sub          ' Only ten buttons are allowed.
  90.     MaxId = MaxId + 1                   ' Increment the button count.
  91.     Load OptButton(MaxId)               ' Create a new button.
  92.     OptButton(0).SetFocus               ' Reset the button selection.
  93.     ' Place the new button below the previous button.
  94.     OptButton(MaxId).Top = OptButton(MaxId - 1).Top + 400
  95.     OptButton(MaxId).Visible = True    ' Display the new button.
  96.     OptButton(MaxId).Caption = "Option" & MaxId + 1
  97. End Sub
  98. Private Sub cmdClose_Click()
  99.    Unload Me    ' Unload this form.
  100. End Sub
  101. Private Sub cmdDelete_Click()
  102.     If MaxId <= 1 Then Exit Sub         ' Keep the first two buttons.
  103.     Unload OptButton(MaxId)             ' Delete the last button.
  104.     MaxId = MaxId - 1                   ' Decrement the button count.
  105.     OptButton(0).SetFocus               ' Reset the button selection.
  106. End Sub
  107. Private Sub optButton_Click(Index As Integer)
  108. ' Index indicates the control that was clicked in the control array.
  109.     picDisplay.BackColor = QBColor(Index + 1)
  110. End Sub
  111.