我想用一下自定义控件,因显示的内容不确定,想自定义LABEL,但报错。请高手指点一下。
我的代码:Private Sub Command2_Click()
Dim qqq As Label
qqq.Width = 150
qqq.Height = 150
qqq.Caption = "dfgdfhdf"
qqq.Top = 2000
qqq.Left = 0
End Sub
...全文
403打赏收藏
自定义控件问题
我想用一下自定义控件,因显示的内容不确定,想自定义LABEL,但报错。请高手指点一下。 我的代码:Private Sub Command2_Click() Dim qqq As Label qqq.Width = 150 qqq.Height = 150 qqq.Caption = "dfgdfhdf" qqq.Top = 2000 qqq.Left = 0 End Sub
Option Explicit
Private WithEvents btnObj As CommandButton
Private WithEvents lblObj As Label
Private Sub btnObj_Click()
MsgBox "This is a dynamically added button."
End Sub
Private Sub lblObj_Click()
MsgBox "This is a dynamically added Label."
End Sub
Private Sub Form_Load()
Set btnObj = Controls.Add("VB.CommandButton", "btnObj")
With btnObj
.Visible = True
.Width = 2000
.Caption = "动态Button"
.Top = 1000
.Left = 1000
End With
Set lblObj = Controls.Add("VB.Label", "lblObj")
With lblObj
.Visible = True
.Width = 2000
.Caption = "动态Label"
.Top = 800
.Left = 800
End With
End Sub