tags:

views:

630

answers:

3

In other languages you can use strings as keys:

PHP:

$array['string'] = 50; 
$array['anotherstring'] = 150;

Is this possible in VBA?

+1  A: 

Have you considered the Dictionary object?

http://msdn.microsoft.com/en-us/library/aa164502(office.10).aspx

Remou
What would be the advantage of a Dictionary object over a simple collection?
David-W-Fenton
A: 

I haven't used VBA in a long time, but those are not arrays, they are hashes (in perl) and associative arrays (in PHP). If you are looking for an answer, you might get better results searching for one of those terms and VBA instead of just "array".

As far as I know, there is no native hash table type in VBA, but like I said, it has been a while since I used it, so I may be wrong.

gpojd
+4  A: 

In VBA you can create a Collection object. Items in the collection can be accessed by index (Long integer) or by a string key.

Joe