aravinthaan@yah 发表于 2022-7-6 15:04:30

如何为添加运行时事件

尊敬的各位:,
 
如何在VBA中为命令按钮添加运行时事件。
 
 
Dim with Events RuntimeCommandButton As CommandButton
 
私有子命令按钮1\u Click()
 
对于i=0到3
设置RuntimeCommandButton=UserForm3。控制。添加(“Forms.CommandButton.1”,“RuntimeCommandButton”,True)
 
使用RuntimeCommandButton
'.左=RuntimeTextBox。左+运行时文本框。宽度+10
.top=(i*20)
.宽度=30
.高度=15
.名称=(i*20)
 
以结束
下一个
 
用户窗体3.Show
 
 
末端接头
 
 
Private Sub RuntimeCommandButton\u Click()
MsgBox“hai”
末端接头
 
 
这是我的代码,事件只在userform3控件中最后添加的命令按钮起作用。我想为所有运行时添加的命令按钮添加事件
页: [1]
查看完整版本: 如何为添加运行时事件