Results 1 to 6 of 6

Thread: Open ActiveX Control Dynamically

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ireland, Dublin
    Posts
    76

    Unhappy

    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.



    Thx

    IJ
    ---------------------------------
    TopMan
    ---------------------------------

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    I can't test this one at the moment, but could you not use :
    Code:
    Dim ActX as object
    Set ActX = Createobject(strconv(vOption))
    Set ActX = new vOption
    
    With ActX
      .container = form1 
      ....
    type thing ?

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    Can't test this either. I thought you couldn't create controls with CreateObject, only new instances of classes.

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    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 ... and it shows how to add it with the Controls method
    Last edited by alex_read; Apr 11th, 2001 at 02:26 AM.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    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!!!

  6. #6
    gaffa
    Guest
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width