UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> GetMember    
(Difference between revisions)
Revision as of 09:35, 6 April 2011
Jleach (Talk | contribs)
(removed header altercation notice)
← Previous diff
Current revision
DatAdrenaline (Talk | contribs)
(corrected the text to indicate the value returned if no member was found. Prior text indicated a Null, but Variants initialize to Empty, not Null, thus the change in comment text.)
Line 1: Line 1:
[code]' Code courtesy of UtterAccess Wiki [code]' Code courtesy of UtterAccess Wiki
-' http://www.utteraccess.com/wiki/index.php/Category:FunctionLibrary 
-' Original submission by Walter Niesz 
-' August 4, 2010 
-' 
' DESCRIPTION ' DESCRIPTION
' Many times it is necessary to retrieve a component of some delimited string of characters. ' Many times it is necessary to retrieve a component of some delimited string of characters.
' This function allows you to specify the delimiter, as well as the position it resides in. ' This function allows you to specify the delimiter, as well as the position it resides in.
-' If no member is found at that position, Null is returned.+' If no member is found at that position, the special value of Empty is returned.
' The default delimiter is a comma (,) ' The default delimiter is a comma (,)
' The default position is 1 ' The default position is 1

Current revision

CODE
' Code courtesy of UtterAccess Wiki
' DESCRIPTION
' Many times it is necessary to retrieve a component of some delimited string of characters.
' This function allows you to specify the delimiter, as well as the position it resides in.
' If no member is found at that position, the special value of Empty is returned.
' The default delimiter is a comma (,)
' The default position is 1

Public Function GetMember(Domain As String, Optional Position As Long = 1, Optional Delimiter As String = ",") As Variant

   Dim MyArray
   
   'no string passed; exit
   If Domain = "" Then Exit Function
   
   MyArray = Split(Domain, Delimiter)
   
   'domain does not contain entry at given position; exit
   If LBound(MyArray) > Position - 1 Or UBound(MyArray) < Position - 1 Then Exit Function
   
   GetMember = MyArray(Position - 1)

End Function


Creative Commons License
GetMember by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search


Thank you for your support!
This page has been accessed 8,246 times.  This page was last modified 19:00, 21 May 2012 by Brent Spaulding. Contributions by Jack Leach and Walter Niesz  Disclaimers