?
Solved

Creating new controls on the fly (VB6)

Posted on 2003-03-31
5
Medium Priority
?
152 Views
Last Modified: 2008-03-10
I have an application that needs to create new controls on the fly (a label control and button to be precise). Is this possible?

rd707

0
Comment
Question by:rd707
[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
5 Comments
 
LVL 26

Accepted Solution

by:
EDDYKT earned 200 total points
ID: 8238070
0
 
LVL 4

Expert Comment

by:iozturk
ID: 8238089
Best approach may be create one with index property set to 0 then  use the code something like

Load Label1(i)
Label1(i).Caption = "Set Caption"
Label1(i).Top = Label1(i-1).Top + 200
Label1(i).Visible = True
0
 
LVL 2

Expert Comment

by:IeuanJ
ID: 8238848
Most cant be created as new in the strictest sense.  For example you cannot simply create a new label.  Iozturk has already mentioned the solution I use to get around this, simply create one indexed instance of the object as design time and then create more instances later.

Just be careful to unload them when finished as they tend to casue major memory usage if you dont.
0
 
LVL 3

Expert Comment

by:QJohnson
ID: 8239210
Labels don't need code behind them, so you can just add as many to the projects as you want with the .Add method of the Controls collection.

Buttons aren't much use without code, though.  So the control array techinque that is being suggested above is your best bet for those.  
0
 

Expert Comment

by:CleanupPing
ID: 8531265
Hi rd707,
This old question (QID 20568715) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

771 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