Getting index of array

Getting index of array

Anonymous
Not applicable
216 Views
2 Replies
Message 1 of 3

Getting index of array

Anonymous
Not applicable
I have an array (single column) that can have up to 400 items in it. I want
to get to the specific index number for an item in the array without going
through a For loop (because it's taken FOREVER!); I already know the name of
the item I just need the corresponding index number.

I tried the following (n is a variant, CAP is one of the objects in the
array) but it doesn't work.
n = array("CAP")

Then I tried to create the array with a second column that is populated by
the index number. For example:
ELBOW, 0
FLANGE, 1
UNION, 2
CAP, 3
PUMP, 4

The code I used still doesn't give me the index number.
n = vvarray("CAP", 1)

If I know the object name why can't I get the associated index number??

Thanks,
--
--
Seth Cohen
Group Leader-Design Department
Mystaire Division
Misonix, Inc.
0 Likes
217 Views
2 Replies
Replies (2)
Message 2 of 3

Ed__Jobe
Mentor
Mentor
Seth, you may want to consider storing your info in a collection rather than an array. It is automatically indexed according to the key value so you can retrieve info using the collections Item method, which is what you're trying to do. With the sample data you provided stored in a collection called MyCol, MyCol.Item("CAP") would return 3. -Ed

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 3

Anonymous
Not applicable
Seth - see my last reply to your original post below.

Jacob

"Ed_Jobe" wrote in message news:f0ec2ed.0@WebX.maYIadrTaRb...
> Seth, you may want to consider storing your info in a collection rather
than an array. It is automatically indexed according to the key value so you
can retrieve info using the collections Item method, which is what you're
trying to do. With the sample data you provided stored in a collection
called MyCol, MyCol.Item("CAP") would return 3. -Ed
>
0 Likes