
Signature
Running MS VB 6.0 Pro (SP5) on Win2K-SR2
For email, use Usenet-20031220 at spamex.com
"What's the recommended way to get from a text string to an array
index?"
Use the split function to take a string with certain delimeters and turn it into an array.
> What's the recommended way to get from a text string to an array
> index?
[quoted text clipped - 34 lines]
>
> Thanks
Top Spin - 30 Jul 2004 01:57 GMT
>"What's the recommended way to get from a text string to an array
>index?"
>
>Use the split function to take a string with certain delimeters and turn it into an array.
I am getting the text one word at a time -- there is nothing to split.
>> What's the recommended way to get from a text string to an array
>> index?
[quoted text clipped - 34 lines]
>>
>> Thanks

Signature
Running MS VB 6.0 Pro (SP5) on Win2K-SR2
For email, use Usenet-20031220 at spamex.com
> What's the recommended way to get from a text string to an array
> index?
The simple method would be to use the keys in a collection
Dim NameIndex As Collection
Set NameIndex = New Collection
' Now add the names and indices:
NameIndex.Add 1, "Joe"
NameIndex.Add 2, "Sue"
NameIndex.Add 3, "Bob"
' To get the index back out, use the name (key)
index = NameIndex("Sue") ' Returns 2
The keys are case sensative, if you don't want case
sensativity, then add the members in a case insensative way:
NameIndex.Add 1, "joe"
NameIndex.Add 2, "sue"
NameIndex.Add 3, "bob"
and be sure to check for them in the same manner:
index = NameIndex("sue")
HTH
LFS
Wolff - 30 Jul 2004 07:31 GMT
> The keys are case sensative, if you don't want case
> sensativity, then add the members in a case insensative way:
At least in VB6 keys of collection items are not case sensitive.
Wolff
Top Spin - 30 Jul 2004 13:27 GMT
>> What's the recommended way to get from a text string to an array
>> index?
[quoted text clipped - 13 lines]
>
> index = NameIndex("Sue") ' Returns 2
That sounds like exactly the solution I was looking for. I will work
on that. Thanks.

Signature
Running MS VB 6.0 Pro (SP5) on Win2K-SR2
For email, use Usenet-20031220 at spamex.com
Top Spin - 31 Jul 2004 02:38 GMT
>> What's the recommended way to get from a text string to an array
>> index?
[quoted text clipped - 13 lines]
>
> index = NameIndex("Sue") ' Returns 2
If I understand this correctly, the collection mechanism associates a
set of "items" with a set of "keys":
object.add item,key
The items can be of type numeric or string, but the keys are strings.
Once added, I can use the key ("Sue") to get to the item (2):
?NameIndex("Sue")
2
But how to I get the key (2) to get to the item ("Sue")?
Thanks
>The keys are case sensative, if you don't want case
>sensativity, then add the members in a case insensative way:
[quoted text clipped - 6 lines]
>
> index = NameIndex("sue")
On my machine, "Sue", "sue", and "SUE" all seemed to work the same

Signature
Running MS VB 6.0 Pro (SP5) on Win2K-SR2
For email, use Usenet-20031220 at spamex.com
Larry Serflaten - 31 Jul 2004 04:29 GMT
> >> What's the recommended way to get from a text string to an array
> >> index?
> But how to I get the key (2) to get to the item ("Sue")?
That wasn't the question. Your question was how to get from the
text string ("Sue") to an index (2).
If you want to go both ways, you might try a Dictionary object,
or depending on the limits, you might use a fixed length string for
the keys and store them all in another string at fixed offsets.
InStr will help you find a Key, and you can divide that found position
by the fixed length to get the index.
LFS
LFS