?
Solved

Adding multiple Labels in a Form

Posted on 2008-10-23
5
Medium Priority
?
250 Views
Last Modified: 2010-04-21
im trying to create multiple labels in a form like we create multiple forms with a form how can i do that?
0
Comment
Question by:BILAL69
[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 5

Expert Comment

by:viju2008
ID: 22789432
can u be more clear with ur question


DO U WANT MULTIPLE LABELS  IN A FORM

THEN ITS AVAILABLE IN THE TOOLBOX  , DRAG AND DROP IT  as many as u want

OR DO U WANT MULITPLE LABELS   AS A CONTROL ARRAY
0
 
LVL 2

Author Comment

by:BILAL69
ID: 22789627
yes i want it like i click the button and it generates a new label automatic
0
 
LVL 4

Expert Comment

by:zstapic
ID: 22790650
Hm... this is not so easy question...

So you might have two different approaches... first, if the number of labels is finite (known) than you can create them and hide them by default. When you click on your button, it should execute a method which will recognize first hidden label and show it :-)

The bigger problem is if you have INFINITE number of labels to add. Than you'll have to use a container, which will be used to possible scroll down to the last label, and also you'll have to create an instances of label class dynamically...

If I can help you with anything else, just ask :-)
0
 
LVL 2

Accepted Solution

by:
Adel87 earned 2000 total points
ID: 22793484
Hi,
The following code should do the trick

since you are adding a label then you wont need to access it later on. but if you want to add a remove button also then you would need to add the Labels you are creating to an array to access it later on.

if you need further assistance please let me know.

Regards,
Private Sub Command1_Click()
 
    Dim c As Control
    ' Create and add the new control.
    Set c = Controls.Add("VB.Label", "Text1" & (Controls.Count + 1))
    ' Change the location of the label on the form
    c.Top = (500 * Controls.Count)
    ' Make the new control visible.
    c.Visible = True
    ' Set the initial caption.
    c.Caption = "Hello" & (Controls.Count + 1)
 
    ' Retrieve the text from the new Label.
    MsgBox (c.Caption)
 
End Sub

Open in new window

0
 
LVL 2

Author Closing Comment

by:BILAL69
ID: 31509337
thnx alot
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

800 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