VB通过Controls.Add添加的控件怎么点击?
PrivateSubForm_Load()Setplayyy=Controls.Add("VB.CommandButton","playyy",Me)Withplayyy...
Private Sub Form_Load()
Set playyy = Controls.Add("VB.CommandButton", "playyy", Me)
With playyy
.Visible = True
.Top = 100 + 500
.Left = 3000
.Caption = "Test"
End With
End Sub
Private Sub playyy_Click()
MsgBox "haha"
End Sub
点击生成的按纽没反应,哪错了?
已自己解决,前面定义的时候加上 withEvents
Dim WithEvents playyy As CommandButton 展开
Set playyy = Controls.Add("VB.CommandButton", "playyy", Me)
With playyy
.Visible = True
.Top = 100 + 500
.Left = 3000
.Caption = "Test"
End With
End Sub
Private Sub playyy_Click()
MsgBox "haha"
End Sub
点击生成的按纽没反应,哪错了?
已自己解决,前面定义的时候加上 withEvents
Dim WithEvents playyy As CommandButton 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
2个回答
展开全部
Private WithEvents cmdObject As CommandButton
Private Sub Form_Load()
Set cmdObject = Form1.Controls.Add("VB.CommandButton", "cmdOne")
cmdObject.Visible = True
cmdObject.Caption = "Dynamic CommandButton"
End Sub
Private Sub cmdObject_Click()
Print "This is a dynamically added control"
End Sub
Private Sub Form_Load()
Set cmdObject = Form1.Controls.Add("VB.CommandButton", "cmdOne")
cmdObject.Visible = True
cmdObject.Caption = "Dynamic CommandButton"
End Sub
Private Sub cmdObject_Click()
Print "This is a dynamically added control"
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询