Microsoft & .NETVisual BasicAdd the Tokens in a Delimited List to a Collection

Add the Tokens in a Delimited List to a Collection

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

This routine simply adds each token in a delimited list to a collection:

Public Sub AddListToCollection_(ByRef cCollection As Collection, _List As String, Delimiter As String)    Dim llDelimiterPos As Long    Dim lsWorkingList As String    lsWorkingList = List    llDelimiterPos = InStr(1, lsWorkingList,_       msCOMMA, vbTextCompare)    Do While llDelimiterPos > 0      cCollection.Add Mid$(lsWorkingList, 1,_       llDelimiterPos - 1)      lsWorkingList = Mid$(lsWorkingList,_       llDelimiterPos + 1)      i = i + 1      llDelimiterPos = InStr(1, lsWorkingList,_       msCOMMA, vbTextCompare)    Loop    If Len(lsWorkingList) > 0 Then      cCollection.Add lsWorkingList    End IfEnd Sub

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories