• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

Dynamically load objects

How do I load (in run time) ActiveX UserControl that I created ?
I mean like duplicate object as TextBox ...
0
vbyuval
Asked:
vbyuval
1 Solution
 
crazymanCommented:
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")



0
 
James_stillmanCommented:
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)
0
 
KhollADCommented:
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
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
modijsCommented:
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.
0
 
vbyuvalAuthor Commented:
Thanks James !
Thats what I looked for .
Want pts ???
0
 
vbyuvalAuthor Commented:
oops I didn't see the Accept comment as answer button ...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now