By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,646 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,646 IT Pros & Developers. It's quick & easy.

Reference to an object

P: 7
In actionscripting you can make a referrence to a _root level object named "button1" by following code:

x=1
_root["button" add x]

Is there a way how I can do the same with VB 6.0?
Nov 21 '06 #1
Share this Question
Share on Google+
4 Replies


100+
P: 267
In actionscripting you can make a referrence to a _root level object named "button1" by following code:

x=1
_root["button" add x]

Is there a way how I can do the same with VB 6.0?
hi

for vb translation i should know what you're trying to do with this button
can you explain in human readable text ?
Nov 21 '06 #2

Expert 5K+
P: 8,434
for vb translation i should know what you're trying to do with this button
can you explain in human readable text ?
What is a "_root level object"?
Nov 21 '06 #3

P: 7
hi

for vb translation i should know what you're trying to do with this button
can you explain in human readable text ?
there are 3 labels named lbl1,lbl2,lbl3
there are 3 string variables called var1,var2,var3

I want to change the caption of lbl1,lbl2,lbl3 respectivly equal to var1,var2,var3
It's true that I can do it manualy. But I'm searching for a easier way. In actionscripting this can be done with the following code
Expand|Select|Wrap|Line Numbers
  1. for(x=1;x<=3;x++){
  2. _root["lbl" add x].caption=_root["var" add x}
  3. }
  4.  
Nov 27 '06 #4

Expert 5K+
P: 8,434
there are 3 labels named lbl1,lbl2,lbl3
there are 3 string variables called var1,var2,var3

I want to change the caption of lbl1,lbl2,lbl3 respectivly equal to var1,var2,var3
It's true that I can do it manualy. But I'm searching for a easier way. In actionscripting this can be done with the following code
...
In VB, this will be a lot easier if the labels are in a control array, and the variables are also an array. That way, you could just code something like
Expand|Select|Wrap|Line Numbers
  1. For x = 1 To 3
  2.   lbl(x) = var(x)
  3. Next
If the controls are not in an array, you could sort of work around it by bulding the name as a string. For example...
Expand|Select|Wrap|Line Numbers
  1. For x = 1 To 3
  2.   Me.Controls("lbl" & Format(x)) = var(x)
  3. Next
If the variables are not in an array, then I don't think you'd have much option but to code them each as individual statements. Arrays make life much simpler.
Nov 27 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.