vba array question

  • Thread starter Thread starter Jame
  • Start date Start date
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
 
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)
 
Back
Top