你用一下代码试试:
dim withevents cmd1 as commandbutton
set cmd1=me.controls.add("VB.CommandButton", "cmd1")
with cmd1
.top=500
.height=500
.left=500
.width=500
.visible=true
.zorder
end with
dim withevents cmd1 as commandbutton
set cmd1=me.controls.add("VB.CommandButton", "cmd1")
with cmd1
.top=500
.height=500
.left=500
.width=500
.visible=true
.zorder
end with
C:\Program Files\Microsoft Visual Studio\MSDN\2001JUL\1033\SAMPLES\VB98\CtlsAdd可能您的 MSDN版本不同,安装位置不同而不同:)楼顶的代码还差了一点点就是动态添加的控件也可以存在事件private sub cmd1_click()
msgbox "u pressed cmd1"
end sub