I have some data in a DataTable, including a column of RTF (Rich Text
Format) data. I wanted to be able to create a comma or tab-delimited
string which I could then put on the clipboard, and then retrieve back
later on or send it to Excel.

I used a StringBuilder to 'build' the text string. What happened,
though, is that after the first string line was created (separated by a
carriage return/line feed), I added additional lines but they never
show up when getting the string back via the StringBuilder ToString. I
checked the data length of the string as I was building it, and it did
increase constantly in size; however, only that first record would show
up on the display and when I did the ToString. This also occured even
if I did a plain old concatenation via & or Concat.

I -THINK- it has something to do with the RTF field being placed on the
string - it almost seems that after the first one is placed no other
strings are displayed (even they the length says they are being added).

So... The real question is: If I have to build a string that is
composed of multiple RTF fields, how do I do that


Chimp (Tom)

Re: Visual Basic Language Store RTF text as string on clipboard?


Can you post a small example of the code that you are using to build the string, set the value, and then retrieve it You didn't mention what the "display" object is, and it may be that the string comes back fine and its a format issue.

Re: Visual Basic Language Store RTF text as string on clipboard?

Riquel Dong ĘC MSFT


Based on your post, I know when you add new string to previous string. It is separated by carriage return and line feed. They are never shown up when you get the string back by class StringBuilder instance method ToString( ) .If you use the following code to add carriage return and line feed.

Code Snippet

Public str As String = "I am billy " & Chr(13) & "" & Chr(10) & "new line"

You try to change it by Enviroment.NewLine.

Code Snippet

Public str As String = "I am billy" + Enviroment.NewLine + " new line"

Hope this can help you !