
Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
In vb, how do I do a lookup of a value in an array or table of elements.
ie bjsorens is my userid, how do I lookup in the array to get 336 where the
array is biult in with values of users and ext?
Again the array or table would have a userid of 8 length and ext of 3 length
bjsorens 336
rewelin 415
reellis 613
If usewr is bjsorens, how do I look up in this array to get 336?
Thanks,
Bryan
> You haven't given enough information to do more than stab a guess at what
> you are doing however
[quoted text clipped - 16 lines]
> > Thanks,
> > Bryan
bryan - 24 Nov 2007 17:02 GMT
A little more clarity
I have variable strUserID.
I want to get the 2nd dimentional value where strUserID = the 1st
dimentional value.
Coming from the AS/400 world I can do this with a lookup in a compile time
array.
Something like:
stringA lookup array1
if %found
move array2 txt1
endif
Thanks,
Bryan
> In vb, how do I do a lookup of a value in an array or table of elements.
> ie bjsorens is my userid, how do I lookup in the array to get 336 where the
[quoted text clipped - 29 lines]
> > > Thanks,
> > > Bryan
bryan - 24 Nov 2007 17:07 GMT
A little more clarity.
I have strUserID.
With this I want to lookup up the match in array element 1 and get array
element 2 which would be the phone ext.
Thanks,
Bryan
> In vb, how do I do a lookup of a value in an array or table of elements.
> ie bjsorens is my userid, how do I lookup in the array to get 336 where the
[quoted text clipped - 29 lines]
> > > Thanks,
> > > Bryan
Graham Mayor - 25 Nov 2007 10:46 GMT
If your items are in an array then you can read the array as follows
Dim sExtension As String
Dim UserId As Variant
UserId = Array("bjsorens336", "rewelin415", "reellis613")
sExtension = Right(UserId(0), 3)
MsgBox sExtension
Where UserID = 0 ie bjsorens336
Checkout vba help on Array

Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> A little more clarity.
> I have strUserID.
[quoted text clipped - 46 lines]
>>>> Thanks,
>>>> Bryan
bryan - 25 Nov 2007 14:52 GMT
I am using this:
Dim USERID
Dim iarray(4)
Dim ares
Dim smd
Dim ext
USERID = GetUserName
'Test array
iarray(0) = "bjsorens336"
iarray(1) = "rewelin112"
iarray(2) = "chadman223"
iarray(3) = "alyssa334"
ares = Filter(iarray, USERID, True, vbTextCompare)
Dim i
For i = 0 To UBound(ares)
smd = ares(i)
Next
ext = Right(smd, 3)
> If your items are in an array then you can read the array as follows
>
[quoted text clipped - 58 lines]
> >>>> Thanks,
> >>>> Bryan