Passing Formatted text

Are there any data types in VB6 that allow me to pass formatted text from a rich text box control?
LVL 18
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think you can use a string as follows

  strRTFToPass = RichTextBox1.TextRTF

The text will be passed as is.  The formating is part of a the control itself. Depending on where you are passing the text to you may be able to preserve the formating by doing a Copy/Paste (using the clipboard object)
The following shows all the RTF formating on my VB6.

Private Sub Command1_Click()
    Dim strRTFToPass As String
    strRTFToPass = RichTextBox1.TextRTF
    MsgBox strRTFToPass
End Sub
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Property TextRTF As String
    Member of RichTextLib.RichTextBox
    Returns/sets the text of a RichTextBox control, including all .RTF code.

The string contains the RTF code required for formatting. Mine shows ...

{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 MS Sans Serif;}}
\viewkind4\uc1\pard\lang1033\f0\fs24 Hi, this is \b bold\b0  text.
\par \f1\fs17
\par }

Crash2100Author Commented:
is there any way I can pass and return RTF from something like a Mid function?
This will return the part that is selected in the contyrol

 strPartialRTF = RichTextBox1.SelRTF
Do you want to get the RTF code for a part of the string?
Sorry, typo . . .

contyrol should be control
For programatically selecting the text in the control, use the SelLength and SelStart properties...

Use rtf.SelStart to specify the start of the selection, rtf.SelLength to specify the length, then use the rtf.selRTF property to get the RTF code of the selected text.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

just out of curiosity, could you please tell me what difference did you see between " ashoooo's " answer and mine?

Crash2100Author Commented:
I'm going to use the SelStart and SelLength properties to change the text directly in the rich text box, instead of passing the text.
If you want, you can split the points, or give him all the points. I dont mind.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.