Your best bet will probably be to use a control array. Name all your controls LED and set their index (0, 1, etc)
Make your sub
Sub Change_LED_To_Green(Index as Long)
frmMain.LED(Index).LoadPic
End Sub
Main Topics
Browse All TopicsI'm trying to figure out how to pass the name of a control to a function that can set the properties of that control. In other words, if I have 10 image controls with names like "LED_1", "LED_2", "LED_3" etc., is there a way to change the properties without spelling out the name of each. Example:
Call Change_LED_to_Green("LED_1
...
...
...
Sub Change_LED_to_Green(Contro
frmMain.ControlName.LoadPi
End Sub
Obviously the code above doesn't work, but what I'd like to find out if there is a way to do this.
For anyone who knows foxpro, I'm looking for a VB version of Foxpro's macro substitution
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Alternatively you could enumerate the controls on the form looking for the appropriate one. e.g.
Sub Change_LED_to_Green(Contro
Dim c As Control
For Each c In frmMain.Controls
If c.Name = ControlName Then
Call c.LoadPicture ("C:\Images\Green.gif")
Exit Sub
End If
Next c
End Sub
Regards
GK
Question(s) below appears to have been abandoned. Administration has been contacted and you will be advised by Email. Your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.
For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
http://www.experts-exchang
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process. Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, in the event new items have been created since this listing was pulled.
http://www.experts-exchang
To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchang
http://www.experts-exchang
http://www.experts-exchang
http://www.experts-exchang
http://www.experts-exchang
http://www.experts-exchang
http://www.experts-exchang
http://www.experts-exchang
http://www.experts-exchang
PLEASE DO NOT AWARD THE POINTS TO ME.
------------> EXPERTS: Please leave any comments regarding this question here on closing recommendations if this item remains inactive another three days.
Thank you everyone.
Moondancer
Moderator @ Experts Exchange
P.S. For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
Business Accounts
Answer for Membership
by: nigelrowePosted on 2001-05-29 at 06:50:01ID: 6132987
And if you put them in a control array?. Then you would only have one name. You then address them by index, something like....
Picture("C :\Images\G reen.gif")
Sub Change_LED_to_Green(ByVal intindex as Integer)
frmMain.Led(intindex).Load
End Sub