I have a comma delimited "list" in a string variable that I iterate
over in a For loop. Currently, I first split the list into an array
and then iterate over the array.

searchfor = "album,artist,genre"
searchtags = Split(searchfor, ",", -1, vbTextCompare)
For Each tag In searchtags
...
Next

Is there a simpler way to do this, without having to split the list
first?

Re: Easy way to iterate through text list? by Marty

Marty
Sat Mar 15 23:15:49 CDT 2008


A lot of this is personal preference, you could skip storing the array
in a variable you might only use one time:

searchfor = "album,artist,genre"
For Each tag In Split(searchfor, ",", -1, vbTextCompare)
'...
Next


But I think the way you posted is more clear and better practice.


-----Original Message-----
From: JJ [mailto:jim.mcatee@gmail.com]
Posted At: Saturday, March 15, 2008 5:36 PM
Posted To: microsoft.public.scripting.vbscript
Conversation: Easy way to iterate through text list?
Subject: Easy way to iterate through text list?

I have a comma delimited "list" in a string variable that I iterate
over in a For loop. Currently, I first split the list into an array
and then iterate over the array.

searchfor = "album,artist,genre"
searchtags = Split(searchfor, ",", -1, vbTextCompare)
For Each tag In searchtags
...
Next

Is there a simpler way to do this, without having to split the list
first?


--
Posted via a free Usenet account from http://www.teranews.com