Posted By

ScryptKeeper on 08/18/08


Tagged

windows vbscript


Versions (?)

stringToList (VBScript)


 / Published in: Visual Basic
 

Takes a delimited string and a the delimiter, and returns a dynamic arrary

  1. Function stringToList(AString, ADelimt)
  2.  
  3. Dim theList()
  4. Dim work
  5. Dim c1, arCount
  6.  
  7. work = AString
  8. c1 = 1
  9. arCount = -1
  10. Do While (c1 > 0)
  11. c1 = InStr(work,ADelimt)
  12.  
  13. If c1 > 0 Then
  14. arCount = arCount + 1
  15. ReDim Preserve theList(arCount)
  16.  
  17. theList(arCount) = Left(work,(c1-1))
  18.  
  19. work = Mid(work,c1+1,Len(work))
  20. End If
  21. Loop
  22.  
  23. arCount = arCount + 1
  24. ReDim Preserve theList(arCount)
  25. theList(arCount) = work
  26. stringToList = theList
  27.  
  28. End Function

Report this snippet  

You need to login to post a comment.