What is the correct syntax for multiple row strings?

  • Thread starter Thread starter Trint Smith
  • Start date Start date
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)
 
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 "
 
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)
 
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
 
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
 
What about:

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

Kevin
(e-mail address removed)
 
Back
Top