Solved

Passing Formatted text

Posted on 2003-10-27
12
249 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
  • 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

828 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