?
Solved

Passing Formatted text

Posted on 2003-10-27
12
Medium Priority
?
252 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 200 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

777 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