vb 类 动态 添加 控件

引用:http://zhidao.baidu.com/question/66115499.html

clsTask
____________________________
Private lbl As Label
Private frm As Form


Public Property Let Owner(ByVal vNewValue As Form)
Set frm = vNewValue
End Property

Public Sub AddPanel(ByVal strCaptiop As String)
Set lbl = frm.Controls.Add("VB.Label", "lbl1")
lbl.Move 1000, 1000, 1000, 1000
lbl.Caption = strCaptiop
lbl.Visible = True
End Sub

form
__________
Private Sub Form_Load()

Dim a As New clsTask
a.Owner = Me
a.AddPanel ("1243")
End Sub
原文地址:https://www.cnblogs.com/sode/p/2245588.html