-
I am trying to add together the contents of rich text boxes without loosing the text formatting. The first example allows an array of RTB to be added together. As soon as I try to include the formatting (RTF) the result is an empty string. Can anybody explain please?
This works but doesn't copy format:
RichTextBox2.Text = ""
For x = 0 To 3
RichTextBox2.Text = RichTextBox1(x).Text + _RichTextBox2.Text
Next x
This doesn't work, it returns an empty string:
RichTextBox2.TextRTF = ""
For x = 0 To 3
RichTextBox2.TextRTF = RichTextBox1(x).TextRTF + RichTextBox2.TextRTF
Next x
[Edited by Ping on 03-30-2000 at 08:35 AM]
-
I got this out of the VB6 help under concatenation operators:
Remarks
When you use the + operator, you may not be able to determine whether addition or string concatenation will occur. Use the & operator for concatenation to eliminate ambiguity and provide self-documenting code.
It then says that if one operator is a variant and one isn't, and if one of them contains is null, the answer will be null, but if you use &, then it will convert to a string and concatenate.
So I would say try it with & as the concatenation character instead of +.
-
Thanks for the help. I tried that but still didn't work. In the end I cut the { } off of the formatting in each element of the array, added the strings and formatting, and then put the curlies back at either end. Finally the string was saved to the .textRTF and hey presto... formatting in tack, in single string. Seems long winded but it works.
Thanks again.