Solved

how to color a text inside a text file

Posted on 2007-11-26
8
154 Views
Last Modified: 2010-04-30
Hello Experts,
how can i make  colored text ia file.txt by code?



0
Comment
Question by:aitsu01
[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
8 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 20350050
Hello aitsu01,

Text files by definition do not have formatting such as colored fonts.

Regards,

Patrick
0
 

Author Comment

by:aitsu01
ID: 20350144
hello  matthewspatrick
thank you for your reply.
can you suggest any other format fyle to use colored fonts?
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20350147
you cannot bring colour in text files. but you can load that text file in vb richtextbox and you can give colours to it. for further idea regarding this

Please look at

http://www.ostrosoft.com/vb/projects/rtf_color/index.asp
0
Industry Leaders: 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 22

Expert Comment

by:danaseaman
ID: 20350187
You can load the plain text into a RichTextBox control and then apply color or font formatting by code.
At this point though you will have to save the file as TextRTF to preserve the formatting.
Option Explicit
 
Private Sub Form_Load()
   Dim s As String
   s = "Hello World"
   RichTextBox1.Text = s
   RichTextBox1.SelLength = Len(s)
   RichTextBox1.SelColor = vbRed
   RichTextBox1.SelBold = True
   RichTextBox1.SelLength = 0
   'Save RichTextBox1.TextRTF to file
   Debug.Print RichTextBox1.TextRTF
End Sub

Open in new window

0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20356607
aitsu01, Did you get what you expected on your requirement.
0
 

Author Comment

by:aitsu01
ID: 20356643
hello shnsunder,
i am working on it but my problem is how to save the text color on my file.txt
how do can i add a richtextbox in my project??
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20357027
Press Ctrl T and choose Microsoft Rich textbox control 6.0.

you can find the rtf control in the tools menu.

insert it in your form.
0
 
LVL 17

Accepted Solution

by:
Shanmuga Sundaram earned 125 total points
ID: 20357048
Sorry you can find the rtf control in the tools box.

once you are able to get the colur in the richtext box then save it in a file using RichTextBox1.SaveFile "C:\123.txt". So that you can open this file in future which will consists of colur formatting codes inside it.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

751 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