Click to See Complete Forum and Search --> : CreateObject Problem
maudie
May 17th, 1999, 11:35 AM
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") ??...
Lothar Haensler
May 17th, 1999, 11:42 AM
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.
maudie
May 18th, 1999, 05:00 AM
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
Lothar Haensler
May 18th, 1999, 06:29 AM
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.
maudie
May 18th, 1999, 01:07 PM
Thanks Lothar. Problem Solved...
Roger...................................
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.