Microsoft & .NET Visual Basic Add the Tokens in a Delimited List to a Collection

Add the Tokens in a Delimited List to a Collection

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

Latest Posts

Related Stories