Solved

Variable label name

Posted on 2003-10-30
10
183 Views
Last Modified: 2010-05-01
I am attempting to display an array by using labels.  However, I need to be able to use a variable within the label name to know what to display.

For example:

         For i = 1 to intNumNodes
                ToNode(i) = intValue
         Next i

        lblNode(i).caption = intValue     <---------- This is the problem

I have labels named lblNode1, lblNode2, etc.

I appreciate any helped provided.

Thanks,
Jeff

0
Comment
Question by:bowen18
[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
  • 4
  • 3
  • 3
10 Comments
 
LVL 48

Expert Comment

by:Mikal613
ID: 9651024
What type is IntValue?
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 9651067
For i = 1 to intNumNodes
                ToNode(i) = intValue
         Next i
for i = 1 to Innumnodes
        lblNode(i).caption = intValue    
next i
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 9651069
For i = 1 to intNumNodes
                ToNode(i) = intValue
         Next i

 for i = 0 to Innumnodes - 1
        lblNode(i).caption = intValue    
next i
0
Industry Leaders: 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!

 
LVL 2

Author Comment

by:bowen18
ID: 9651100
IntValue is an integer.  However, the problem is with the lblNode(i).caption line.  VB doesn't accept that as a valid label name.  Is there some way to include the varible i within the label name?
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 500 total points
ID: 9651106
You could use an array of labels!! matching some like this:

  For i = 1 to intNumNodes
                lblNode(i).caption  = ToNode(i)
 Next i

Or see CallByname function in MSDN Help.
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 9651159
Are yo using .NET ?? if so
try lblnode.Text = whatever
0
 
LVL 2

Author Comment

by:bowen18
ID: 9651170
Using version 6.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9651193
Well, it appears to be a "two-way only" thread so, good luck!.
Cheers
0
 
LVL 2

Author Comment

by:bowen18
ID: 9651215
-Richie_Simonetti

Thanks I'm using your suggestion with the label array.  Never used it before, but makes perfect sense in this case.

Thanks,
Jeff
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9651282
Array of controls use less resources than using label1, label2, label3 and so on.
You could use array of each vb intrinsic controls and almost all ocx.
Cheers ... again.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

749 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