Solved

Variable label name

Posted on 2003-10-30
10
169 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
  • 4
  • 3
  • 3
10 Comments
 
LVL 48

Expert Comment

by:Mikal613
Comment Utility
What type is IntValue?
0
 
LVL 48

Expert Comment

by:Mikal613
Comment Utility
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
Comment Utility
For i = 1 to intNumNodes
                ToNode(i) = intValue
         Next i

 for i = 0 to Innumnodes - 1
        lblNode(i).caption = intValue    
next i
0
 
LVL 2

Author Comment

by:bowen18
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 48

Expert Comment

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

Author Comment

by:bowen18
Comment Utility
Using version 6.
0
 
LVL 16

Expert Comment

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

Author Comment

by:bowen18
Comment Utility
-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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now