Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Arrays

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bryan - 22 Nov 2007 19:01 GMT
document.new
I get the userid from a module and want to populate a text field with the
user's phone extension.
Here's an example of user's and phone ext:
bjsorens336
rewelin415
reellis613

Thanks,
Bryan
Graham Mayor - 24 Nov 2007 13:59 GMT
You haven't given enough information to do more than stab a guess at what
you are doing however

Dim sExtension As String
sExtension = Right(UserID, 3)
ActiveDocument.FormFields("Text1").Result = "Ext: " & sExtension

will put the last three characters that form the extension number of your
variable UserID in a text form field Text1

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> document.new
> I get the userid from a module and want to populate a text field with
[quoted text clipped - 6 lines]
> Thanks,
> Bryan
bryan - 24 Nov 2007 14:44 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.