2

I need to store a multiline string inside a variable:

dim str as string = "
    some words
    some words
    some
    words
"

How?

  • Add Environment.NewLine where you want the line break – Steve Jun 08 '13 at 17:12
  • 1
    @Steve thanks 'cause that's a solution but really I want to avoid the usage of "newlines" because I have texts of a large number of lines, I cannot set a multiline string in vbnet as C# multiline strings? –  Jun 08 '13 at 17:16
  • You don't want to use Environment.NewLine but want newlines in the string? – unlimit Jun 08 '13 at 17:20
  • you might consider using external text file if your text is extremely large. – ajakblackgoat Jun 08 '13 at 18:17
  • possible duplicate of [Multiline strings in VB.NET](http://stackoverflow.com/questions/706382/multiline-strings-in-vb-net) – Damith Jun 08 '13 at 18:21

4 Answers4

8

No need to use the classes to insert new lines, you can do it like this:

Dim Logo As String= <a><![CDATA[
___  ___        _  _    _  _  _              
|  \/  |       | || |  (_)| |(_)             
| .  . | _   _ | || |_  _ | | _  _ __    ___ 
| |\/| || | | || || __|| || || || '_ \  / _ \
| |  | || |_| || || |_ | || || || | | ||  __/
\_|  |_/ \__,_||_| \__||_||_||_||_| |_| \___|


 _____  _          _                         
/  ___|| |        (_)                        
\ `--. | |_  _ __  _  _ __    __ _           
 `--. \| __|| '__|| || '_ \  / _` |          
/\__/ /| |_ | |   | || | | || (_| |          
\____/  \__||_|   |_||_| |_| \__, |          
                              __/ |          
                             |___/           
]]></a>.Value

Console.WriteLine(Logo)
dbasnett
  • 11,334
  • 2
  • 25
  • 33
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
1

VB.Net has no such feature and it will not be coming in Visual Studio 2010.

look Multiline strings in VB.NET for workarounds

Community
  • 1
  • 1
varun
  • 4,522
  • 33
  • 28
  • dont you mean has not come in visual studio 2010 or 2012, refering to a prduct that has been released in the future tense is slightly strange. – user1937198 Jun 08 '13 at 18:46
0

Make it like this ..

dim str as string = "some words" & vbCrlf & "some words" & vbCrlf & "some" & vbCrlf & "words"

OR try it with vbLf

matzone
  • 5,703
  • 3
  • 17
  • 20
0

you can use XML for this like

dim vrstr as string = <s>
    some words
    some words
    some
    words
</s>
Jack Gajanan
  • 1,596
  • 14
  • 18