VB怎么用代码创建控件数组?
1个回答
展开全部
先定义一个控件(Option1),然后修改index值为0 ,就创建了控件数组,设置你要创建控件数组的其它属性.
Private Sub Form_Load()
Dim i%
For i = 1 To 3
Load Option1(i) ' 这句是关键,,,,,
Option1(i).Top = Option1(0).Top
Option1(i).Left = Option1(i - 1).Left + Option1(i - 1).Width + 200
Option1(i).Visible = True
Next
Option1(0).Caption = "10"
Option1(1).Caption = "15"
Option1(2).Caption = "20"
Option1(3).Caption = "30"
End Sub
Private Sub Option1_Click(Index As Integer)
Text1.FontSize = Val(Option1(Index).Caption)
End Sub
Private Sub Form_Load()
Dim i%
For i = 1 To 3
Load Option1(i) ' 这句是关键,,,,,
Option1(i).Top = Option1(0).Top
Option1(i).Left = Option1(i - 1).Left + Option1(i - 1).Width + 200
Option1(i).Visible = True
Next
Option1(0).Caption = "10"
Option1(1).Caption = "15"
Option1(2).Caption = "20"
Option1(3).Caption = "30"
End Sub
Private Sub Option1_Click(Index As Integer)
Text1.FontSize = Val(Option1(Index).Caption)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询