Re: read each line of variable (like readline method)? by Al
Al
Fri Jul 16 17:34:57 CDT 2004
"R Dunn" <q1c2_3m4e5t6a7l8@hotmail.com> wrote in message
news:e$fEhY3aEHA.2840@TK2MSFTNGP11.phx.gbl...
> I have a variable that has multiple lines of text - I want to go through
> each one, line by line and perform an action with the information.
>
> I know how to get line information from a text file using the readline
> method, but am unsure of a way to easily do this with a variable. Any
> ideas?
Assuming that the variable contains its lines of text delimited with the
newline character (as would be the case in a text file), the simplest is to
convert it on the fly to an array using the split function, i.e.:
dim lines ' contains multiple lines of text
dim line ' used to extract each line in turn
lines = "line 1" & vbnewline & "line 2" & vbnewline & "line 3"
for each line in split(lines, vbnewline)
wscript.echo "line is: " & line
next
/Al