Solved

Can you index objects in VBA?

Posted on 1998-08-12
3
150 Views
Last Modified: 2010-04-30
I'm converting a standalone application into an Excel VBA application.  In the standalone, I have a series of pictures which are made visible and invisible (so as to animate).  They are Picture6(0) to Picture6(79).  However in Excel, I cannot do this because there is no index property for objects; they must be given entirely unique names.

So my question is, is indexing not allowed at all, or is it done differently that I am not aware of (as with some other small differences that I've noticed).  If it isn't allowed could you please give me some suggestions as to how I would go about doing this?

Thank you.
0
Comment
Question by:leekk
3 Comments
 
LVL 3

Expert Comment

by:dapperry
ID: 1468690
I don't think you can have a control array in VBA.  Perhaps you could call the pictures something
like PICTURE1, PICTURE2, PICTURE3, PICTURE4 - and then use something like the
eval function to refer to them.  I'm not sure of a good way to have common events amoung the objects , like a control array has, so thats why this is just a comment.

:) D Perry
0
 

Accepted Solution

by:
lstefano earned 100 total points
ID: 1468691
What about:
sub ix()
   set md = worksheets(1)
   for i=1 to md.shapes.count
      md.shapes(i).visible=false
   next i
end sub

Notice that the collection Shapes can be indexed by index and/or by name...
0
 

Author Comment

by:leekk
ID: 1468692
Thanx.
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

810 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