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?

Thanks in advance, everyone!
Rob

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



Re: read each line of variable (like readline method)? by McKirahan

McKirahan
Fri Jul 16 21:04:58 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?
>
> Thanks in advance, everyone!
> Rob

Dim arrVAR
Dim intVAR
Dim strVAR
strVAR = {variable}
arrVAR = Split(strVAR,vbCrLf)
For intVAR = 0 To UBound(arrVAR)
WScript.Echo arrVAR(intVAR)
Next



Re: read each line of variable (like readline method)? by R

R
Mon Jul 19 10:02:14 CDT 2004

Nice - vbnewline! I was unaware of that constant. Thanks for the tip -
works like a charm.

Rob


"Al Dunbar [MS-MVP]" <alan-no-drub-spam@hotmail.com> wrote in message
news:uDFVjU4aEHA.3524@TK2MSFTNGP12.phx.gbl...
>
> "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
>
>