?
Solved

Unwanted Codes in Rich Text Boxes

Posted on 2004-09-10
14
Medium Priority
?
210 Views
Last Modified: 2010-05-02
I've written a VB 6.0 program that uses the Rich Text Box tool to display large blocks of text.  Sometimes I'll save a recording using one of these text boxes, and the next time I open it, there are all these codes mixed in with the text like this for example:

{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}

Needless to say, it makes the text hard to read.  How can I prevent this from happening?  Also, is there any way I can cut out blocks that have been "polluted" by the codes and strip to codes out so I can save them clean?

Thanks in advance for any help you can give me.
0
Comment
Question by:Remulac
  • 2
  • 2
  • 2
  • +4
10 Comments
 
LVL 19

Expert Comment

by:Shauli
ID: 12030516
When you load your file, add 0 at the end, as in:

RichTextBox1.LoadFile "yourfilepath&name.rtf", 0

S
0
 
LVL 1

Expert Comment

by:FCouples
ID: 12030543
If you are using the .savefile command with rich text box add a 1 at the end:

RichTextBox1.SaveFile "myfilename.txt", 1

-Jeff
0
 
LVL 3

Expert Comment

by:aParser
ID: 12030552
I was going to sugggest the converse:

RichTextBox1.SaveFile "yourfilepath&name.txt", rtfText ' rtfText = 1; the default is 0 (rtfRTF)
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
LVL 13

Expert Comment

by:Michael_D
ID: 12030620
But be carefull - You are going to lose any formating like diferent fonts, colors, sizes etc. if you will save your .RTF file as regular text
Is this what are you want?
0
 

Author Comment

by:Remulac
ID: 12030703
I should have mentioned that I'm saving this to an Access database using ADO, so I don't know if any of the tricks listed above will help me out.

As far as losing formatting; I'd like to keep indents and what-not, but if that's not possible, I guess it's worth it to lose all those foreign characters.
0
 
LVL 3

Accepted Solution

by:
aParser earned 500 total points
ID: 12030770
So are you setting the .Text property?  You can check the results from your database field for the RTF codes and use the .TextRTF property instead:

If Left$(rs.Fields("MyField").Value, 5) = "{\rtf1" Then
  RichTextBox1.TextRTF = rs.Fields("MyField").Value
Else
  RichTextBox1.Text = rs.Fields("MyField").Value
End If
0
 
LVL 3

Expert Comment

by:rinksno1
ID: 12033573
why are you using the rich text box control(i guess you are not using any formatting in the text box)...you can use text box and change it to multiline and scroll bar set to vertical....

rinks
0
 
LVL 1

Expert Comment

by:InVisal
ID: 12036609
RichTextBox1.TextRTF <--- For RichTextFile Format
RichTextBox1.Text <--- Text Format

Example : i write world "HelloWolrd" in RichTextBox

when you use .TextRTF property it will reture

{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}
\viewkind4\uc1\pard\lang1033\f0\fs17 HelloWorld
\par }

if you use .Text property it will reture

HelloWorld
0
 
LVL 13

Expert Comment

by:Michael_D
ID: 12562556
I Recomend accept last post of aParser as an answer
0
 

Author Comment

by:Remulac
ID: 12736195
Sorry about that, gentlemen.  I need to understand better how this site works.  Where is the most concise explanation of the points system?
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 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…
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…

589 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