Results 1 to 3 of 3

Thread: Why does first work and second doesn't?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    Suffolk. UK
    Posts
    162
    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]

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    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 +.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    Suffolk. UK
    Posts
    162
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width