-
June 19th, 2004, 03:16 AM
#1
object names in code
i'm making a big project that involves a lot of objects with similar settings. i was wondering if there was a way to "carry" an object name to make it easier and less time consuming. let me explain what i mean: i'm making a program that draws electrical circuit diagrams. when the user clicks on an object such as a light bulb or a battery, etc. a popup menu comes up with some settings, such as 'disable object' and 'properties'. when the user clicks an object in the list i want it to perform functions such as making the selected object invisible. my problem is unless i can find a way to carry the object name i'd have to create menus and code for each object on the diagram. for example if i wanted to make a lightbulb invisible i would have imgLightbulb.visible = false but i don't want to have to do this for every object, i would rather have it so that no matter what object was selected, it would still load the same command, like as if i was to make it object.visible = false. if anybody could help it would be greatly appreciated.
thnx alot,
Colt.
-
June 19th, 2004, 05:07 AM
#2
ok i've used an array for the objects which made the problem way easier to handle. i'm still interested to know how i could do this another way, like for example, having a string as an object name and using it like
stringname.visible = true
or something like that.
-
June 19th, 2004, 08:50 AM
#3
I'm not sure I understand what exactly you are doing. If all your objects have the same options and/or properties, and they are in an array, then what's wrong with MyObject(x).Visible = False? Of course, the array would need to support whatever properties you need, and it seems to me that a single array for all types of circuit components would be ideal. This might best be handled by a UDT or class. If you can design a "generic" component, then assigning values to the various properties would determin what it is.
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
June 19th, 2004, 08:38 PM
#4
Originally posted by WizBang
I'm not sure I understand what exactly you are doing. If all your objects have the same options and/or properties, and they are in an array, then what's wrong with MyObject(x).Visible = False? Of course, the array would need to support whatever properties you need, and it seems to me that a single array for all types of circuit components would be ideal. This might best be handled by a UDT or class. If you can design a "generic" component, then assigning values to the various properties would determin what it is.
no no the array works fine. when i originally asked the question i had (stupidly) forgotten my past ideas for an array of the objects. anyway i was just wondering if there was another way without using an array. but it's ok i wasn't going to use any new methods cuz i'm on a strict schedule.
thnx anyway,
Colt
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|