![]() |
The equivalence of EQUIVALENCE
I've read elsewhere in this group that a construct like Fortran's
EQUIVALENCE doesn't exist in VBA, so let me please share the goal and perhaps someone has a suggestion. I want to access certain elements of an array by individual names. This is mostly for clarity of programming, bug avoidance, etc. The array construct is necessary because several operations have to be done on the array as a whole, but writing and reading portions of it would be much easier to document for those who follow if the individual elements had meaningful variable names like tempLosAngeles instead of temp(6,9,7). All bright ideas appreciated, and thanks. |
The equivalence of EQUIVALENCE
Richard,
Maybe you could use a collection, which allows you to define a key for each member. hth, Doug Glancy "Richard" wrote in message om... I've read elsewhere in this group that a construct like Fortran's EQUIVALENCE doesn't exist in VBA, so let me please share the goal and perhaps someone has a suggestion. I want to access certain elements of an array by individual names. This is mostly for clarity of programming, bug avoidance, etc. The array construct is necessary because several operations have to be done on the array as a whole, but writing and reading portions of it would be much easier to document for those who follow if the individual elements had meaningful variable names like tempLosAngeles instead of temp(6,9,7). All bright ideas appreciated, and thanks. |
The equivalence of EQUIVALENCE
"Doug Glancy" wrote ...
I've read elsewhere in this group that a construct like Fortran's EQUIVALENCE doesn't exist in VBA, so let me please share the goal and perhaps someone has a suggestion. I want to access certain elements of an array by individual names. This is mostly for clarity of programming, bug avoidance, etc. The array construct is necessary because several operations have to be done on the array as a whole, but writing and reading portions of it would be much easier to document for those who follow if the individual elements had meaningful variable names like tempLosAngeles instead of temp(6,9,7). Maybe you could use a collection, which allows you to define a key for each member. What a great title for a post! The trouble with a Collection is that is impossible AFAIK to retrieve the keys. I'm told this is possible with the scripting Dictionary object, which also offers additional methods. However, both a Collection and a Dictionary are essentially one dimensional. So, when I need something more capable than a Collection, I use a fabricated (disconnected) ADO Recordset, which has some very useful properties and methods (Sort, Filter, GetRows, etc). Records and Fields = 2D of course but another dimension may be added eith by using key columns or even by fabricating a hierarchical recordset (i.e. a recordset of recordsets) using the SHAPE provider and syntax. There are some articles on MSDN e.g. http://support.microsoft.com/default...b;en-us;196029 Jamie. -- |
All times are GMT +1. The time now is 11:07 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com