PDA

Click to See Complete Forum and Search --> : Open ActiveX Control Dynamically


IrishJoker
Apr 5th, 2001, 09:04 AM
Hi,

I was hoping someone would be able to help me.
I am sending a UserControl Name to a function. The
function is recieveing the Name into a variant variable
called vOption.

Does anyone know how I can open the User Control
through code.

:D

Thx

IJ

alex_read
Apr 6th, 2001, 05:56 AM
I can't test this one at the moment, but could you not use :

Dim ActX as object
Set ActX = Createobject(strconv(vOption))
Set ActX = new vOption

With ActX
.container = form1
....

type thing ?

agent
Apr 10th, 2001, 03:59 PM
Can't test this either. I thought you couldn't create controls with CreateObject, only new instances of classes.

alex_read
Apr 11th, 2001, 02:21 AM
Wasn't sure on this one, so needed to look it up for you, scrub that - I think you're right that you can't use the createobject option for this.

Take a look at the paragraph heading "Dynamic Control Creation" from this web site / page ... (http://www.vbhow.to/articles/fb1298/fb1298.asp) and it shows how to add it with the Controls method :)

agent
Apr 11th, 2001, 03:07 PM
I have seen the light and it is good.

My god, I have been wondering how to dynamically create a control at runtime since I bought vb5. I now know that it's not possible in vb5 without heavy API usage, but vb6...this is great!!!

gaffa
Apr 12th, 2001, 04:23 AM
Francesco Balena wrote an article in VBPJ about 2 or 3 years ago about creating controls dynamically (ie: not using the Controls.Add method) that works a treat. I've it in production apps, had not problems

- gaffa