UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> GetMember    
' Code courtesy of UtterAccess Wiki
' 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,356 times.  This page was last modified 19:00, 21 May 2012 by Brent Spaulding. Contributions by Jack Leach and Walter Niesz  Disclaimers