# VB6 的做法

Posted by Sephiroth on June 24, 1999 at 17:20:30:

In Reply to: Re: 如何用程式产生多个Label? posted by South Wind on June 24, 1999 at 09:20:32:

VB6 动态建立控制项的方法:

Private WithEvents mobjLabel As VB.Label

Private Sub Form_Load()
Set mobjLabel = Controls.Add("VB.Label", "Label1")
With mobjLabel
.Caption = "Label1"
.Move 0, 0, 1500, 300
.Visible = True
End With
End Sub

动态建立的控制项可以是任意控制项, 只要不把 TypeLib 打错就行了. 当然 UserControl 也可以
动态建立, 但是要注意, 如果 UserControl造不出来就必须把 Alt-P-E Upgrade ActiveX Controls
的选项取消.

Follow Ups:

- Re: VB6 的做法 (更正) Sephiroth 09:00:31 6/25/99 (0)