Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dynamic addition of controls to a control.

Posted on 1999-01-25
3
Medium Priority
?
151 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 600 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

705 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