Solved

Unwanted Codes in Rich Text Boxes

Posted on 2004-09-10
14
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +4
14 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 125 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

717 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