VB怎么用代码创建控件数组?
2个回答
展开全部
先定义一个控件(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
展开全部
先定义一个控件(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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |