Visual Basic > Strings
Returns a specific token from a delimited string list.
Returns a specific token from a delimited string list. ' Returns : [string] "Token" (section of data) from a list of ' delimited string data ' ' Requires : [string] delimited data, ' [integer] index of desired section, ' [string] delimiter (1 or more chars) ' ' Declare :Function GetToken(ByVal strVal As String, intIndex As Integer, _ ' strDelimiter As String) As String Dim strSubString() As String Dim intIndex2 As Integer Dim i As Integer Dim intDelimitLen As Integer intIndex2 = 1 i = 0 intDelimitLen = Len(strDelimiter) Do While intIndex2 > 0 ReDim Preserve strSubString(i + 1) intIndex2 = InStr(1, strVal, strDelimiter) If intIndex2 > 0 Then strSubString(i) = Mid(strVal, 1, (intIndex2 - 1)) strVal = Mid(strVal, (intIndex2 + intDelimitLen), Len(strVal)) Else strSubString(i) = strVal End If i = i + 1 Loop If intIndex > (i + 1) Or intIndex <1 Then GetToken Else GetToken="strSubString(intIndex" 1) End If End Function
Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows