Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Unwanted Codes in Rich Text Boxes

Posted on 2004-09-10
14
Medium Priority
?
206 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Suggested Courses

885 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