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

x
?
Solved

how to color a text inside a text file

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



0
Comment
Question by:aitsu01
8 Comments
 
LVL 93

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
Suggested Courses

886 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