一、动态添加CommandButton命令按钮
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/diannaorumen/)Dim mc As CommandButton
Static k
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/diannaorumen/)k = k + 1
Set mc = Me.Controls.Add("Forms.Commandbutton.1")
mc.Caption = k
mc.Top = Me.Controls(k - 1).Top + Me.Controls(k - 1).Height
Me.Controls.Remove "Commandbutton1"
二、动态添加文本框
Set myText = Controls.Add( "VB.TextBox ", "myTextBox ")
With myText
.Visible = True
.Text = "这是加载的动态控件 "
.Width = 3200
End With