vba array question

J

Jame

Hi everyone,

I'm trying to retrieve the value from the collection that
contains array and I'm having errors. Here is the code.

Dim tmp As New Collection

tmp.Add Item:=Array("Hi","World"), Key:="0"


Whenever I try to retrieve the the values "Hi", I'm
getting a error with invaild call. Here is the code to
retrieve it.

MsgBox tmp.Item(0)(0).

Any help is appreciated

Thanks,

Jame
 
M

Marshall Barton

Jame said:
Dim tmp As New Collection

tmp.Add Item:=Array("Hi","World"), Key:="0"


Whenever I try to retrieve the the values "Hi", I'm
getting a error with invaild call. Here is the code to
retrieve it.

MsgBox tmp.Item(0)(0).


The collection's numeric index starts at 1, not 0.

Either use:
tmp.Item(1)(0)
or
tmp.Item("0")(0)
or
tmp(1)(0)
or
tmp("0")(0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top