Solved

Unwanted Codes in Rich Text Boxes

Posted on 2004-09-10
14
204 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
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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 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…

777 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