Become a Columnist Microsoft Exchange Site Microsoft Support SiteMSDN Exchange Site

       How did you like this article? Please vote and let us know.          

Subscribe to OutlookExchange
Anderson Patricio
Ann Mc Donough
Bob Spurzem
Brian Veal
Catherine Creary
Cherry Beado
Colin Janssen
Collins Timothy Mutesaria
Drew Nicholson
Fred Volking
Glen Scales
Goran Husman
Guy Thomas
Henrik Walther
Jason Sherry
Jayme Bowers
John Young
Joyce Tang
Justin Braun
Konstantin Zheludev
Kristina Waters
Kuang Zhang
Mahmoud Magdy
Martin Tuip
Michael Dong
Michele Deo
Mitch Tulloch
Nicolas Blank
Pavel Nagaev
Ragnar Harper
Ricardo Silva
Richard Wakeman
Russ Iuliano
Santhosh Hanumanthappa
Shannal L. Thomas
Steve Bryant
Steve Craig
Todd Walker
Tracey J. Rosenblath

 

 
 

This form illustrates converting a keywords field such as categories to an array of strings.

menu.gif
Download SetArray.OFT

Sub CommandButton1_Click()
Dim i
'Remove the comment from stop if you want to step the code
'Stop
varArray=SetArray(Item.Categories)
For i = 0 to UBound(varArray)
MsgBox "Array Element " & i & ": " & varArray(i,0)
Next
End Sub

'******************************************************************************
'Custom procedure: SetArray
'Created by: Randy Byrne, MVP Outlook 97
'Company Name: Micro Eye, Microsoft Certified Solution Provider
'E-Mail: randy_byrne@msn.com
'Date: 1/3/98
'Purpose: Convert keywords field (array of strings) into array of variants
'VBScript Usage: varArray = SetArray(Item.Categories)
'******************************************************************************
Function SetArray(ByVal strCategories)
Dim i
Dim iDelim
Dim strFind
Dim strToken
Dim MyArray
Dim iTokenCount
'Find the number of elements in keywords field
iTokenCount=0
strFind = strCategories
Do Until strFind = ""
iDelim = InStr(1, strFind, ",")
If iDelim <> 0 Then
strToken = LTrim(RTrim(Mid(strFind, 1, iDelim - 1)))
Else
strToken = strFind
End If
If iDelim <> 0 Then
strFind = Mid(strFind, iDelim + 1)
Else
strFind = ""
End If
iTokenCount = iTokenCount + 1
Loop
If iTokenCount > 0 then
iTokenCount=iTokenCount - 1
End If
'Dimension the array using the number of elements in keywords field (i-1)
Redim MyArray(iTokenCount,0)
'Reset strFind
strFind = strCategories
Do Until strFind = ""
iDelim = InStr(1, strFind, ",")
If iDelim <> 0 Then
strToken = LTrim(RTrim(Mid(strFind, 1, iDelim - 1)))
Else
strToken = strFind
End If
MyArray(i, 0) = Trim(strToken)
If iDelim <> 0 Then
strFind = Mid(strFind, iDelim + 1)
Else
strFind = ""
End If
i = i + 1
Loop
'Return MyArray as SetArray
SetArray = MyArray
End Function


Disclaimer: Your use of the information contained in these pages is at your sole risk. All information on these pages is provided "as is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Pro Exchange. OutlookExchange.Com and Pro Exchange shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

© Copyright Pro Exchange, Inc., 2006