Look at the Split function, and ReplaceLineEndings function. (If you are already certain about the line ending used, you can skip the latter in this case.)
Assuming you already know the line endings, and assuming they are linefeeds (Chr(10)), the code is simply this:
// ps has your string
dim lines() as string = ps.Split( Chr( 10 ) )
for i as integer = 0 to lines.Ubound
ListBox1.AddRow( lines( i ) )
nexti
I did this to get rid of the extra line it was adding to the end.
dim lines() as string = theResult.Split( Chr( 10 ) )
for i as integer = 0 to lines.Ubound
if lines(i) = "" then
else
ListBox1.AddRow( lines( i ) )
end
next i
theResult = theResult.Trim
dim lines() as string = theResult.Split( Chr( 10 ) )
for i as integer = 0 to lines.Ubound
ListBox1.AddRow( lines( i ) )
next i
However, if there might be blank lines within theResult and you want to skip them, your code above is better.