What is the correct syntax for multiple row strings?

T

Trint Smith

How can I get multiple rows in a string?

string1 = "row1 of file" &_
"row2 of file" &_
"row3 of file"

do something with the next string2, like get info from sql server 2k
and:
for i string2 next

string3 = "row20 of file" &_
"row21 of file" &_
"lastrow of file"

I can't seem to get the quotes or something right for "&_" right. I
always get a syntax error.
Thanks,
Trint


.Net programmer
(e-mail address removed)
 
C

Cor

Hi Trint,

Are you Dutch, you can spent some more spaces, than it will work I asume?

Cor

string1 = "row1 of file " & _
"row2 of file " & _
"row3 of file "
 
T

Trint Smith

Great! That works...but how do I have a carriage return at the end of
each row in a string. I tried this:
string1 = "row1 of file \cr" &_
"row2 of file \cr" &_
"row3 of file"


..Net programmer
(e-mail address removed)
 
A

Armin Zingler

Trint Smith said:
Great! That works...but how do I have a carriage return at the end
of each row in a string. I tried this:
string1 = "row1 of file \cr" &_
"row2 of file \cr" &_
"row3 of file"

string1 = "row1 of filer" & vbcrlf & _
"row2 of file \cr" & vbcrlf & _
"row3 of file"

Instead of vbcrlf you can use
- vbNewLine
- environment.newline
- ControlChars.CrLf
- ControlChars.NewLine


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
A

Armin Zingler

Trint Smith said:
Great! That works...but how do I have a carriage return at the end
of each row in a string. I tried this:
string1 = "row1 of file \cr" &_
"row2 of file \cr" &_
"row3 of file"

....and:
For building a larger string and/or with an undetermined number of lines,
you might consider using the System.IO.StringWriter class, offering a
WriteLine method.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
K

Kevin White

What about:

string1 = "row1 of file" & vbCrLf & _
"row2 of file" & vbCrLf & _
"row3 of file" & vbCrLf

Kevin
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top