动态生成控件! Dim WithEvents myBtn As VB.CommandButtonPrivate Sub Command1_Click() Set myBtn = Controls.Add("VB.CommandButton", "CmdButton1")With myBtn .Caption = "New Command" .Visible = True End With End SubPrivate Sub myBtn_Click() MsgBox "Clicked" End Sub滚动条在另一个贴子里我已经贴了!
忘了你要的是文本框,用下面这个吧! Dim WithEvents mytxt As VB.TextBoxPrivate Sub Command1_Click() Set mytxt = Controls.Add("VB.TextBox", "text1")With mytxt .Text = "This is a New TextBox" .Visible = True End With End SubPrivate Sub mytxt_Click() MsgBox "Clicked" End Sub
忘了你要的是文本框,用下面这个吧! Dim WithEvents mytxt As VB.TextBoxPrivate Sub Command1_Click() Set mytxt = Controls.Add("VB.TextBox", "text1")With mytxt .Text = "This is a New TextBox" .Visible = True End With End SubPrivate Sub mytxt_Click() MsgBox "Clicked" End Sub
Dim WithEvents myBtn As VB.CommandButtonPrivate Sub Command1_Click()
Set myBtn = Controls.Add("VB.CommandButton", "CmdButton1")With myBtn
.Caption = "New Command"
.Visible = True
End With
End SubPrivate Sub myBtn_Click() MsgBox "Clicked"
End Sub滚动条在另一个贴子里我已经贴了!
Dim WithEvents mytxt As VB.TextBoxPrivate Sub Command1_Click()
Set mytxt = Controls.Add("VB.TextBox", "text1")With mytxt
.Text = "This is a New TextBox"
.Visible = True
End With
End SubPrivate Sub mytxt_Click()
MsgBox "Clicked"
End Sub
Dim WithEvents mytxt As VB.TextBoxPrivate Sub Command1_Click()
Set mytxt = Controls.Add("VB.TextBox", "text1")With mytxt
.Text = "This is a New TextBox"
.Visible = True
End With
End SubPrivate Sub mytxt_Click()
MsgBox "Clicked"
End Sub
已经给出,能否请教另一个问题:怎样让文本框在 Picturebox 内生成,谢谢 !!!