Hi to all.
Is there a way to have multiline strings in VB.NET like python
a = """
multi
line
string
"""
or php
$a = <<<END
multi
line
string
END;
?
Of course something that is not
"multi" & _
"line
Thanks
Hi to all.
Is there a way to have multiline strings in VB.NET like python
a = """
multi
line
string
"""
or php
$a = <<<END
multi
line
string
END;
?
Of course something that is not
"multi" & _
"line
Thanks
No, VB.NET does not yet have such a feature. It will be available in the next iteration of VB (visual basic 10) however (link)
if it's like C# (I don't have VB.Net installed) you can prefix a string with @
foo = @"Multiline
String"
this is also useful for things like @"C:\Windows\System32\" - it essentially turns off escaping and turns on multiline.
VB.Net has no such feature and it will not be coming in Visual Studio 2010. The feature that jirwin is refering is called implicit line continuation. It has to do with removing the _ from a multi-line statement or expression. This does remove the need to terminate a multiline string with _ but there is still no mult-line string literal in VB.
Example for multiline string
Visual Studio 2008
Dim x = "line1" & vbCrlf & _
"line2"
Visual Studio 2010
Dim x = "line1" & vbCrlf &
"line2"
You can use XML Literals to achieve a similar effect:
Dim s As String = <a>Hello
World</a>.Value
Remember that if you have special characters, you should use a CDATA block:
Dim s As String = <a><![CDATA[Hello
World & Space]]></a>.Value
Well, since you seem to be up on your python, may I suggest that you copy your text into python, like:
s="""\
this is gonna
last a few lines
"""
then do a:
for i in s.split('\n'):
print 'mySB.AppendLine("%s")' % i
or
for i in s.split('\n'):
print '"%s " & _' % i
then at least you can copy that out and put it in your VB code. Bonus points if you bind a hotkey (fastest to get with:Autohotkey) to do this for for whatever is in your paste buffer. The same idea works good for a SQL formatter.