VB怎么用代码创建控件数组?
发布网友
发布时间:2022-05-19 23:12
我来回答
共3个回答
热心网友
时间:2023-10-19 23:52
先定义一个控件(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
热心网友
时间:2023-10-19 23:53
先定义一个控件(Option1),在他的基础上创建数组,设置你要创建控件数组位置,最后设置值,下面是一个列子,你看哈,不懂就Q我
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)
Select Case Index
Case 0
Text1.FontSize = 10
Case 1
Text1.FontSize = 15
Case 2
Text1.FontSize = 20
Case 3
Text1.FontSize = 30
End Select
End Sub
热心网友
时间:2023-10-19 23:53
先定义一个控件,然后再赋值,赋新值,然后修改index值