Solved

Passing Formatted text

Posted on 2003-10-27
12
246 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now