|
|
Title | Find a specific entry in a delimited string (VB6) |
Keywords | delimited string, Split, VB6 |
Categories | Tips 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.
|
|
-->
|
|