Function StrSpan1(sTarget As String, sSeps As String) As Integer Dim cTarget As Integer, iStart As Integer cTarget = Len(sTarget) iStart = 1 ' Look for start of token (character that isn't a separator) Do While InStr(sSeps, Mid$(sTarget, iStart, 1)) If iStart > cTarget Then StrSpan1 = 0 Exit Function Else iStart = iStart + 1 End If Loop StrSpan1 = iStart End Function Function StrBreak1(sTarget As String, sSeps As String) As Integer Dim cTarget As Integer, iStart As Integer cTarget = Len(sTarget) iStart = 1 ' Look for end of token (first character that is a separator) Do While InStr(sSeps, Mid$(sTarget, iStart, 1)) = 0 If iStart > cTarget Then StrSpan1 = 0 Exit Function Else iStart = iStart + 1 End If Loop StrSpan1 = iStart End Function Public Function GetToken1(sTarget As String, sSeps As String) As String ' Note that sSave and iStart must be static from call to call ' If first call, make copy of string Static sSave As String, iStart As Integer If sTarget <> sEmpty Then iStart = 1 sSave = sTarget End If ' Find start of next token Dim iNew As Integer iNew = StrSpan1(Mid$(sSave, iStart, Len(sSave)), sSeps) If iNew Then ' Set position to start of token iStart = iNew + iStart - 1 Else ' If no new token, return empty string GetToken1 = sEmpty Exit Function End If ' Find end of token iNew = StrBreak1(Mid$(sSave, iStart, Len(sSave)), sSeps) If iNew Then ' Set position to end of token iNew = iStart + iNew - 1 Else ' If no end of token, set to end of string iNew = Len(sSave) + 1 End If ' Cut token out of sTarget string GetToken1 = Mid$(sSave, iStart, iNew - iStart) ' Set new starting position iStart = iNew End Function