Inserting CRLF with String.Format 
Author Message
 Inserting CRLF with String.Format

Is it possible to insert a CRLF into a string with String.Format?

Currently, I have had to resort to the following, which seems less that
optimal.

strMessage &= String.Format("{0} = {1}", strName, strValue) &
Environment.NewLine

Thanks in advance for any help.

Sincerely,
Frank J. Reashore, MCSD

Vancouver
Canada



Wed, 21 Sep 2005 08:42:28 GMT  
 Inserting CRLF with String.Format
Hello Frank,


Quote:
> Is it possible to insert a CRLF into a string with String.Format?

???

\\\
Dim s As String
s = String.Format("Hallo{0}Welt", ControlChars.CrLf)
MsgBox(s)
///

Regards,
Herfried K. Wagner



Wed, 21 Sep 2005 08:49:07 GMT  
 Inserting CRLF with String.Format

Quote:
> Is it possible to insert a CRLF into a string with String.Format?

Yes

Quote:
> Currently, I have had to resort to the following, which seems
> less that optimal.

> strMessage &= String.Format("{0} = {1}", strName, strValue) &
> Environment.NewLine

Possible is also

strMessage &= String.Format("{0} = {1}{2}", strName, strValue,
Environment.NewLine)

Or use a Stringbuilder.

--
Armin



Wed, 21 Sep 2005 08:54:25 GMT  
 Inserting CRLF with String.Format

Example:


This is line 2.
This is line 3.";

MessageBox.Show(myString);

This code prints out:

This is line 1.
This is line 2.
This is line 3.


tabs, so you don't want to indent the second and third lines of the code
to make everything line up in the code editor, or you'll get something
like:

This is line 1.
        This is line 2.
        This is line 3.

It looks a sort of ugly in the code editor, because you actually have to
type lines 2 and 3 against the far left margin to get all three lines to
line up.  Give it a try.

Karen Martinez

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Wed, 21 Sep 2005 23:01:11 GMT  
 Inserting CRLF with String.Format
I'm sorry, I wrote my previous reply in C#.  I read both the C# and VB
newsgroups and forgot to look at which one I was replying to.

StringBuilder is your best bet, as the previous posters indicated.

Karen Martinez

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Wed, 21 Sep 2005 23:11:11 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. INSERT INTO Fails if the value contains a CRLF

2. ADO cannot get the string formatted for insert

3. Find whether a string has a CRLF contained within it

4. Finding CRLF in string

5. Q: Replacing delimiter with CRLF (string function?)

6. CRLF in strings.

7. Problem with format on insert autotext, and in inserting elements with form fields

8. HOW TO APPEND/INSERT STRING TO ANOTHER STRING

9. Insert string into a string

10. Not able to format with String.Format

11. Inserting attachments in body for RTF format.

12. Inserting PPT Slides but keeping the format

 

 
Powered by phpBB® Forum Software