# VB6 动态新增控制项做法

Posted by Sephiroth on July 08, 1999 at 15:28:48:

没办法, 只好举个例子让大家看看: (VB6 适用)

Option Explicit

Private WithEvents Command1 As CommandButton

Private Sub Command1_Click()
MsgBox "Click Me!"
End Sub

Private Sub Form_Click()
Set Command1 = Controls.Add("VB.CommandButton", "Command1")
With Command1
.Caption = "Run-Time Create"
.Move (ScaleWidth - .Width) \ 2, (ScaleHeight - .Height) \ 2
.Visible = True
End With
End Sub

Follow Ups:

- Re: VB6 动态新增控制项做法 Ringo 15:15:33 7/11/99 (0)
- Sephiroth 谢谢你 小吴 10:05:38 7/09/99 (0)