Solved

Passing Formatted text

Posted on 2003-10-27
12
248 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 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