Solved

how to color a text inside a text file

Posted on 2007-11-26
8
153 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 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
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.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Support for Notepad++ (including downloading & installing a plugin) 5 162
Excel Automation VBA 19 91
IF ELSE Statement in Excel Macro VBA 16 75
Problem to refer to value 8 63
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…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
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…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

830 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