|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
heredoc-like syntax in VB.Net?I would like to send a boatload of pre-formatted text to a string or
stream. Is there a way to do this in VB.Net similar to the way heredoc works in other languages? -- Dennis Dennis,
Can you be a little more expressive then a boatload of pre-formatted text In fact it is then \\\ dim heremedoc as new stringbuilder For each thestring as string in my boatload heremedoc.Add(thestring Next dim the boatloadloaded = heremedoc.ToString /// Cor Show quoteHide quote "Dennis" <nobody@nowhere.invalid> wrote in message news:a50g25d0vpd4edep52onnf9rbposofa0jn@4ax.com... >I would like to send a boatload of pre-formatted text to a string or > stream. > > Is there a way to do this in VB.Net similar to the way heredoc works in > other languages? > > -- > > Dennis On Thu, 4 Jun 2009 20:15:22 +0200, "Cor Ligthert[MVP]"
<Notmyfirstn***@planet.nl> wrote: >Can you be a little more expressive then a boatload of pre-formatted text I would like to do something similar to the way it works in C#. Here isan example: http://blog.luckyus.net/2009/02/03/heredoc-in-c-sharp/ -- Dennis Hi Dennis,
> I would like to do something similar to the way it works in C#. Here is Either store the text as a System.String setting, and then use > an example: > > http://blog.luckyus.net/2009/02/03/heredoc-in-c-sharp/ My.Settings.NameOfsetting as the variable. Dim boatloadoftext = My.Settings.boatloadoftext Or, Dim boatloadoftext As String = "Line 1" & VbControlChars.CRLF_ "Line 2" & VbControlChars.CRLF _ "Line 3" & VbControlChars.CRLF _ "Line 4" TBH I would go the Settings route, it would mean that you can update the setting in the .config file, this is the "correct" way to do it. Try to avoid using String literals as much as possible. Nick. On Thu, 4 Jun 2009 20:48:43 +0100, "nak" <a@a.com> wrote: This seems to do what I want.>> I would like to do something similar to the way it works in C#. Here is >> an example: >> >> http://blog.luckyus.net/2009/02/03/heredoc-in-c-sharp/ > > > Either store the text as a System.String setting, and then use >My.Settings.NameOfsetting as the variable. > > Dim boatloadoftext = My.Settings.boatloadoftext > Or, Definitely _not_ what I wanted to end up doing.> > Dim boatloadoftext As String = "Line 1" & VbControlChars.CRLF_ > "Line 2" & VbControlChars.CRLF _ > "Line 3" & VbControlChars.CRLF _ > "Line 4" Thanks! -- Dennis Hi Dennis,
> Definitely _not_ what I wanted to end up doing. So you want to simply copy and paste a shed load of text into your code?I'll tell you now, it's bad coding. Store it in a setting, or if you want to localise the text, store it in a resource. Alternatively, don't ask for help if you don't want the correct way of achieving the results you are after, goto planet-source-code.com. Nick. Ignore this, I didn't notice your line "This seems to do what I want."...
LOL! I only saw the last line and thought it was in reference to both solutions, my apologies. Show quoteHide quote "nak" <a@a.com> wrote in message news:4BDD110A-2E73-481F-BBE4-B6A7F1EACF9D@microsoft.com... > Hi Dennis, > >> Definitely _not_ what I wanted to end up doing. > > So you want to simply copy and paste a shed load of text into your > code? > > I'll tell you now, it's bad coding. > > Store it in a setting, or if you want to localise the text, store it in > a resource. > > Alternatively, don't ask for help if you don't want the correct way of > achieving the results you are after, goto planet-source-code.com. > > Nick. >
Show quote
Hide quote
"Dennis" <nobody@nowhere.invalid> wrote in message That's not advisable even if you were using C#...news:be4g2557sbnlfh1d57v4klmsjffkjebb68@4ax.com... > On Thu, 4 Jun 2009 20:15:22 +0200, "Cor Ligthert[MVP]" > <Notmyfirstn***@planet.nl> wrote: > >>Can you be a little more expressive then a boatload of pre-formatted text > > I would like to do something similar to the way it works in C#. Here is > an example: > > http://blog.luckyus.net/2009/02/03/heredoc-in-c-sharp/ > > -- > > Dennis -- Mike Maybe my macro at http://www.helixoft.com/blog/archives/12 can help you.
-- Peter Macej Helixoft - http://www.helixoft.com VSdocman - Commenter and generator of class documentation for C#, VB ..NET and ASP .NET code Dennis wrote:
> I would like to send a boatload of pre-formatted text to a string or Strings in VB don't accept embedded line breaks. You'll eventually> stream. > > Is there a way to do this in VB.Net similar to the way heredoc works in > other languages? have to use string concatenation. Or not: what I do is to create a text file resource. Go to the project properties, and open the Resources tab. Select "Add Resource" >> "Add New Text File" and specify a descriptive name for your string (e.g. SQL_SINCHRONIZE_TABLES, or whatever suits you. Make it descriptive). The IDE creates a new text file with the name you provided in the folder Resources. You can edit this file at will. Now, to use the text, you only need to load it from the My.Resources namesmace: Dim Sql As String = My.Resources.SQL_SINCHRONIZE_TABLES Simple as that. HTH. Regards, Branco. |
|||||||||||||||||||||||