Dynamically load objects

How do I load (in run time) ActiveX UserControl that I created ?
I mean like duplicate object as TextBox ...
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Presuming that it is creatable you need to know its ProgId or versionIndependantprogId

if you search the HKEY_CLASSES_ROOT under your registered class you should find these keys.

you can then create an object using

Dim o as object
set o = createobject("MyProgId.Whatever")

Crazyman is correct if you do not have the object already loaded. However is you want to create a duplicate of an already loaded control. Then set the index of the already loaded control to 0 and to load another control simply type:

load yourControlName(yourControlName.ubound)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
you can use the Dynamic Control Addition features from VB 6.0 :

Private WithEvents TextX As TextBox

Private Sub TextX_Change()

MsgBox "Text Changed"

End Sub

Private Sub Form_Load()
   Set TextX = Controls.Add("VB.Textbox", "TextX")
   With TextX
      .Visible = True
      .Width = 3000
      .Height = 3000
      .Text = "This is a Dynamic TextBox"
      .Top = 0
      .Left = 0
      End With
End Sub
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

i am also interested in this. i tried it using createobject but i couldn't succeed somehow. so keep informing...
using HKEY_CLASSES_ROOT  is it portable i.e. will  this work if the program setup is run on other machine and is used.
vbyuvalAuthor Commented:
Thanks James !
Thats what I looked for .
Want pts ???
vbyuvalAuthor Commented:
oops I didn't see the Accept comment as answer button ...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.