Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
-->
TitleFind a specific entry in a delimited string (VB6)
Keywordsdelimited string, Split, VB6
CategoriesTips and Tricks
 
Gerard Beck sent me this code written by his friend John D. Jegla. It uses Split to break a delimited string into pieces and then returns a selected piece.
 
Function ParseDelimitedString(ByVal a_strTheString As _
    String, ByVal a_intListItem As Integer, ByVal _
    a_strTheDelimiter As String) As String
    On Error Resume Next
    ParseDelimitedString = Split(a_strTheString, _
        a_strTheDelimiter)(a_intListItem - 1)
End Function
 
This code is great for pulling one entry out of the string. However, if you need to process several of the entries, this code would need to call Split once for each entry. If you need to do that, use Split once to make the array of entries and then address the entries you need.

Note also the nice coding style that uses descriptive names and ByVal whenever possible.

 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated