CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 1999
    Location
    UK
    Posts
    33

    CreateObject Problem

    I have a usercontrol which I am trying (without success) to create new instances of on my form.

    The control is called userControl1.

    It is registered as class userControl1.

    How do I CreateObject("usercontrol1") ??...


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: CreateObject Problem

    don't use CreateObject.
    drag and drop it from the toolbox onto your form.
    You may have to select it from the Components dialog on the Project menu.
    You can also dynamically add it to the Controls collection of your form by calling the Add method of that collection in VB 6.


  3. #3
    Join Date
    May 1999
    Location
    UK
    Posts
    33

    Re: CreateObject Problem

    Thanks for reply Lothar; I am a beginner ! using VB5.
    The exact problem I have is that I have a shape which I have created as a usercontrol and which i need the user to be able to place on the form at run time at different x,y coords.
    I need to leave that shape at different places on the form to be viewed together so I need to clone that shape; or have multiple instances of it available which I can identify by a key.
    The shape is in class:usercontrol1. What syntax will produce new instances of it ?

    Thanks....... Roger


  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: CreateObject Problem

    to create new instances of a control there are two ways in vb.

    1. create a control instance at design-time and give it an Index of 0.
    Then, at runtime do a Load controlname(yourIndex)

    and set controlname(yourIndex).visible to True

    2. use the Add method of the Controls collection of the form window.


  5. #5
    Join Date
    May 1999
    Location
    UK
    Posts
    33

    Re: CreateObject Problem

    Thanks Lothar. Problem Solved...


    Roger...................................


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

Featured