Solved

Passing Formatted text

Posted on 2003-10-27
12
250 Views
Last Modified: 2010-05-01
Are there any data types in VB6 that allow me to pass formatted text from a rich text box control?
0
Comment
Question by:Crash2100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 9

Expert Comment

by:Dang123
ID: 9628784
I think you can use a string as follows

  strRTFToPass = RichTextBox1.TextRTF


0
 
LVL 29

Expert Comment

by:leonstryker
ID: 9629084
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)
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9629183
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:ashoooo
ID: 9629328
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 }

0
 
LVL 18

Author Comment

by:Crash2100
ID: 9629379
is there any way I can pass and return RTF from something like a Mid function?
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9629413
This will return the part that is selected in the contyrol


 strPartialRTF = RichTextBox1.SelRTF
0
 
LVL 3

Expert Comment

by:ashoooo
ID: 9629417
Do you want to get the RTF code for a part of the string?
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9629420
Sorry, typo . . .

contyrol should be control
0
 
LVL 3

Accepted Solution

by:
ashoooo earned 50 total points
ID: 9629538
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.
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9715833
Crash2100,

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

0
 
LVL 18

Author Comment

by:Crash2100
ID: 9715884
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.
0
 
LVL 3

Expert Comment

by:ashoooo
ID: 9716137
If you want, you can split the points, or give him all the points. I dont mind.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question