February 28, 2021
Hot Topics:

Add the Tokens in a Delimited List to a Collection

  • By John Dawson
  • Send Email »
  • More Articles »
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

This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date