十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
做一个窗体模板,假设是Form2
成都创新互联公司专注于网站建设,为客户提供成都做网站、成都网站制作、网页设计开发服务,多年建网站服务经验,各类网站都可以开发,品牌网站设计,公司官网,公司展示网站,网站设计,建网站费用,建网站多少钱,价格优惠,收费合理。
Dim x as New Form2
x.Show()
如果弹出窗口较多,x可以用动态数组替代
下面这段代码完成,在窗体上用语句添加2个 GroupBox控件,且在每个GroupBox控件中添加4个 RadioButton 控件。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
'添加2个GroupBox
Dim MyGroupBox(2) As GroupBox
For i = 1 To 2
'将一个GroupBox控件加入到Form上
MyGroupBox(i) = New GroupBox
Me.Controls.Add(MyGroupBox(i))
'设置该GroupBox控件的属性
MyGroupBox(i).Height = 240
MyGroupBox(i).Width = 600
MyGroupBox(i).Top = (i - 1) * (240 + 20) + 20
MyGroupBox(i).Left = 20
'修改新加入控件的Text值
MyGroupBox(i).Text = "GroupBox" CStr(i)
Next
'每个GroupBox中添加4个单选按钮
Dim MyRadioButton1(4) As RadioButton
Dim MyRadioButton2(4) As RadioButton
For i = 1 To 4
MyRadioButton1(i) = New RadioButton
Me.Controls.Add(MyRadioButton1(i))
MyRadioButton1(i).Parent = MyGroupBox(1)
'设置该GroupBox控件的属性
MyRadioButton1(i).Height = 20
MyRadioButton1(i).Width = 120
MyRadioButton1(i).Top = (i - 1) * (20 + 20) + 40
MyRadioButton1(i).Left = 20
'修改新加入控件的Text值
MyRadioButton1(i).Text = "RadioButton1_" CStr(i)
Next
For i = 1 To 4
MyRadioButton2(i) = New RadioButton
Me.Controls.Add(MyRadioButton2(i))
MyRadioButton2(i).Parent = MyGroupBox(2)
'设置该GroupBox控件的属性
MyRadioButton2(i).Height = 20
MyRadioButton2(i).Width = 120
MyRadioButton2(i).Top = (i - 1) * (20 + 20) + 40
MyRadioButton2(i).Left = 20
'修改新加入控件的Text值
MyRadioButton2(i).Text = "RadioButton2_" CStr(i)
Next
End Sub
1,添加一个模块,在模块里声明一个全局公共变量N;
2,在控件的调用窗体代码段里,把此控件名称给这个全局公共变量N赋值;
3,在窗体的Load()事件里,写代码: Me.Text = N。