Have a long literals string in VB? Forget the underscore and just use VB9’s XML Literals
Goto 100 - Development with Visual Basic - Long strings in Visual Basic 2008
“I suspect everyone already knew this – but for me it was shiny and new :-) XML Literals do not require line continuation characters, hence rather than this:
you can create a really long string using an XML Literal:
Note: the whitespace is maintained.” [Post leached in full]
This tip made me laugh as I just thought it was just too cool… And until we get rid of the line continuation character (in VB10, I hope), I think I might be able to use this a trick.
But note the note. Maintained whitespace means the above message would look like;
So if you use this trick, make sure you understand this…
4 comments:
Dude, that's one of the coolest trick I've seen - made my day when I saw that (and I have to use it for an example i'm making).
Very cool :).
It is still a patch to a really really weak language. I mean, why not just get rid of the tags and underscores once and for all. Let the carriage return be the end of the line markup ... damn!
This is fantastic!!! Great tip. I think this improvement would work to avoid the white space issue:
Dim myString As String =
some
more
text.
.Value
myString now holds the value "some more text."
OK that last post should have tags around the values. I guess Blogger can't handle angle brackets in the comments.
Post a Comment