Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Help! how to add componts in a form at runtime

I want to add some command buttons in a form at run-time.
I defined a button in a class module, and try to create a button as bellow:

dim btnRead as vb.commandButton

Private Sub Class_Initialize()
' Set btnRead = New CommandButton ' invalid keyword "New"
' Set btnRead = createObject("vb.CommandButton") ' Can't create object
btnRead .Caption = "Read"
btnRead .index = indexCls ' indexCls is a public integer
End Sub

Public Property Let btn_left(pos As Integer)
btnRead.Left = pos
End Property
Public Property Let btn_top(pos As Integer)
btnRead .Top = pos
End Property
Public Property Let btn_Capt(capt As String)
btnRead .Caption = capt
End Property

This code is not work.
Can anybody help on how to add a run-time component in a form?

Thank you in advance.
[956 byte] By [shuiqq] at [2007-11-11 8:08:41]
# 1 Re: Help! how to add componts in a form at runtime
http://www.google.com/search?q=vb+controls.add
Phil Weber at 2007-11-11 17:25:51 >
# 2 Re: Help! how to add componts in a form at runtime
Thank you, phil.
shuiqq at 2007-11-11 17:27:02 >