?
Solved

Determine Bold,Underline and Italic Characters in rich text box control

Posted on 2005-05-09
4
Medium Priority
?
1,055 Views
Last Modified: 2013-12-03
Hi,

I'm currently doing a project using a rich text control in Visual Basic 6.
I need to output the data from a rich text control into a binary file, remembering what characters font styles have been used within the data (BOLD, UNDERLINE OR ITALIC).

Please help. :->

0
Comment
Question by:LPlate
  • 3
4 Comments
 
LVL 13

Expert Comment

by:rettiseert
ID: 13961227
Hi

You can save the data in a RTF file and preserve all formatting attributes

RichTextBox1.SaveFile "C:\myfile.rtf"
0
 
LVL 13

Expert Comment

by:rettiseert
ID: 13961244
To load the file again use

RichTextBox1.LoadFile "c:\myfile.rtf"
0
 

Author Comment

by:LPlate
ID: 13966095
The Device that I output to only supports Binary format files.

For Example, if the rich text box contains the following data "Hello World I'm in hot water", and lets say all o characters are bold, the output file will look like this:

"HellESC<b>oESC<bo> WESC<b>oESC<bo>rld I'm in hESC<b>oESC<bo>t water"

I need to know what characters are Underline, Bold or Italic to that I can generate the data above.
0
 
LVL 13

Accepted Solution

by:
rettiseert earned 375 total points
ID: 13968819
ok, if you just want to know what chars are underline, bold or italic, use .SelBold, .SelItalic and .SelUnderline properties.

This can give you an idea:

    Dim I As Long
    Dim Result As String
   
    With RichTextBox1
   
        For I = 0 To Len(.Text)
           
            .SelStart = I
            .SelLength = 1
           
            If .SelBold Then Result = Result + "<b>"
            If .SelItalic Then Result = Result + "<i>"
            If .SelUnderline Then Result = Result + "<u>"
       
            Result = Result + .SelText
           
            If .SelUnderline Then Result = Result + "</u>"
            If .SelItalic Then Result = Result + "</i>"
            If .SelBold Then Result = Result + "</b>"
       
        Next
       
    End With
   
    Debug.Print Result
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
Suggested Courses
Course of the Month15 days, 22 hours left to enroll

850 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