Private Sub CommandButton1_Click() Dim AddCom As Control
If AddCom Is Nothing Then Set AddCom = Me.Controls.Add("Forms.CommandButton.1", "CommandButtonA", Me) AddCom.Caption = "ASDADF" AddCom.Move 100, 100, 300, 300 AddCom.Visible = True End If End Sub
代码: Private Sub Form_Load() Dim cmb As MSForms.CommandButton Set cmb = Controls.Add("Forms.CommandButton.1", "cmb") '动态添加 cmb.Left = 10 cmb.Top = 10 cmb.Visible = True End Sub然后在菜单project ->Project Properties -->Make -->去掉选项Remove information about unused Active controls就可以了,但这样虽然代码可以运行了,但这样会使你编译的exe文件得比较大,不推荐使用!
Dim AddCom As Control
If AddCom Is Nothing Then
Set AddCom = Me.Controls.Add("Forms.CommandButton.1", "CommandButtonA", Me)
AddCom.Caption = "ASDADF"
AddCom.Move 100, 100, 300, 300
AddCom.Visible = True
End If
End Sub
Private Sub Form_Load()
Dim cmb As MSForms.CommandButton
Set cmb = Controls.Add("Forms.CommandButton.1", "cmb") '动态添加
cmb.Left = 10
cmb.Top = 10
cmb.Visible = True
End Sub然后在菜单project ->Project Properties -->Make -->去掉选项Remove information about unused Active controls就可以了,但这样虽然代码可以运行了,但这样会使你编译的exe文件得比较大,不推荐使用!
1999-02-09 08:50 370,547 FM20.CHM
1997-04-01 00:00 18,177 FM20.CNT
2000-09-20 23:03 1,109,264 FM20.DLL
2001-06-13 14:16 347,136 FM20.oca
1999-04-26 20:33 26,384 FM20CHS.DLL
1999-07-29 11:11 36,864 FM20ENU.DLL这7个文件添加到文件包中。
(注:将删除未使用的控件信息 取消也没用,在目标机上一样会报错,因为VB在打包FORM2.0时将漏掉两三个DLL文件)