⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 控件数组.frm

📁 蒋加伏主编VB程序设计第四版PPT及全部课本源码 北京邮电大学出版社 Visual Basic 程序设计教程(第四版) 主编 蒋加伏 张林峰 找了好久的(不带密码的)
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "例[7-7] 控件数组"
   ClientHeight    =   2505
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3750
   LinkTopic       =   "Form1"
   ScaleHeight     =   2505
   ScaleWidth      =   3750
   StartUpPosition =   3  '窗口缺省
   Begin VB.OptionButton OptButton 
      Caption         =   "option1"
      Height          =   372
      Index           =   1
      Left            =   2640
      TabIndex        =   2
      Top             =   600
      Width           =   972
   End
   Begin VB.CommandButton Command1 
      Caption         =   "添加按钮"
      Height          =   372
      Left            =   2640
      TabIndex        =   1
      Top             =   120
      Width           =   972
   End
   Begin VB.PictureBox Picture1 
      Height          =   2052
      Left            =   240
      ScaleHeight     =   1995
      ScaleWidth      =   2235
      TabIndex        =   0
      Top             =   120
      Width           =   2292
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Static MaxIdx '必须定义成静态变量
If MaxIdx = 0 Then MaxIdx = 1
MaxIdx = MaxIdx + 1 '获得新建按钮的Index值
If MaxIdx > 4 Then Exit Sub '最多只建4 个按钮
Load OptButton(MaxIdx) '新建控件数组元素
OptButton(MaxIdx).Top = OptButton(MaxIdx - 1).Top + 360 '控件布局
OptButton(MaxIdx).Visible = True
OptButton(MaxIdx).Caption = "option" & MaxIdx
End Sub

Private Sub OptButton_Click(Index As Integer)
Dim H, W
Picture1.Cls
Picture1.FillStyle = Index '设置与控件数组元素下标值相应的填充类型
W = Picture1.ScaleWidth / 2
H = Picture1.ScaleHeight / 2
Picture1.Circle (H, W), W / 2 '画圆
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -