Option Explicit
'声明对象变量为 CommandButton 。
Private WithEvents cmdObject As CommandButtonPrivate Sub Form_Load()
'动态添加按钮
Set cmdObject = Form1.Controls.Add("VB.CommandButton", "cmdOne")
With cmdObject
.Visible = True
.Caption = "动态按钮"
.Width = 1000
.Height = 500
.Top = Form1.Height / 2 - 500
.Left = Form1.Width / 2 - 500
End With
'声明对象变量为 CommandButton 。
Private WithEvents cmdObject As CommandButtonPrivate Sub Form_Load()
'动态添加按钮
Set cmdObject = Form1.Controls.Add("VB.CommandButton", "cmdOne")
With cmdObject
.Visible = True
.Caption = "动态按钮"
.Width = 1000
.Height = 500
.Top = Form1.Height / 2 - 500
.Left = Form1.Width / 2 - 500
End With
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货