Solved

Dynamic addition of controls to a control.

Posted on 1999-01-25
3
146 Views
Last Modified: 2010-05-03
I have created a User-Defined control.  I want to add an array of standard VB Shape controls to my User-Defined control dynamically.  For example,  I want to display an array of multicolored rectangles on my User-Defined control.  I don't know how many rectangles are in the array until the user tells me.   Possible?  If so how?

0
Comment
Question by:nelchr
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 200 total points
ID: 1470577
Place a control named Shape1 on the usercontrol. Set its index property to 0. Then, to add a control, call Load Shape1(1), Load Shape1(2) and so on. After each call, set the .Visible property to true, and reposition the shape (or it can be any other control) using .Left and .Top properties. This is called a control array
0
 

Author Comment

by:nelchr
ID: 1470578
When I do what you suggest I get a subscript out of range on the first addition.  i.e. shape1(1) in your example.  I tried to REdim the array first to its full size but that didn't help.    It looks like you are close but ...
0
 

Author Comment

by:nelchr
ID: 1470579
ok, ok, ok  I got it.  Thanks for your help.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question