Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleCombine values from two RTF text boxes preserving their formatting properties
DescriptionThis example shows how to combine values from two RTF text boxes preserving their formatting properties in Visual Basic 6. It uses the controls' SelRTF properties to get their values complete with formatting information.
KeywordsRTF, Rich Text Box, RichTextBox
CategoriesControls, Strings
 
If you just use the controls' Text or SelText properties, the result loses all rich formatting.

This example selects the text in each control and uses its SelRTF property to get the text complete with formatting information.

 
Private Sub Command1_Click()
    RichTextBox1.SelStart = 0
    RichTextBox1.SelLength = Len(RichTextBox1.Text)

    RichTextBox2.SelStart = 0
    RichTextBox2.SelLength = Len(RichTextBox2.Text)

    RichTextBox3.SelStart = 0
    RichTextBox3.SelLength = Len(RichTextBox3.Text)
    RichTextBox3.SelRTF = RichTextBox1.SelRTF
    RichTextBox3.SelStart = Len(RichTextBox3.Text)
    RichTextBox3.SelLength = 0
    RichTextBox3.SelText = vbCrLf
    RichTextBox3.SelStart = Len(RichTextBox3.Text)
    RichTextBox3.SelLength = 0
    RichTextBox3.SelRTF = RichTextBox2.SelRTF

    RichTextBox1.SelStart = 0
    RichTextBox1.SelLength = 0
    RichTextBox2.SelStart = 0
    RichTextBox2.SelLength = 0
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated