Solved

Writing out to a log with colour font in VB6

Posted on 2003-12-09
8
1,225 Views
Last Modified: 2013-12-03
Hi,

Is it possible to write out to a log file setting the font to a colour i.e., red...?

I am trying to high-light in red only those lines that contain error messages.

I am using VB6 on Windows 2000.

Thanks Ian Carrick
0
Comment
Question by:ISC
8 Comments
 
LVL 1

Author Comment

by:ISC
ID: 9905067

Should also add...

I am using a 'Textstream' object to write out to my log file...


Thanks Ian
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 200 total points
ID: 9905068
sure, use the microsoft rich textbox control (under project/components)

using the properties w/in that control you can specify font color and other characteristics.

then do RichTexbox1.saveFile "test.rtf"

this should save it as a rich text formatted text file and should retain the color info. (this can be opened in wordpad/word/etc...)
0
 
LVL 1

Author Comment

by:ISC
ID: 9905098
Hi,

My VB program does not have a UI.

My program just opens a text file does some processing...during processing events are logged....I only want to high-light certain lines....

Thanks Ian
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 9905374
You can't have text formatting in a plain text file.

You don't need to have the interface visible to the end user to accomplish this.  

bobbit31 has a great idea.  Open the text file and place its contents into a richtextbox control.  Then you can apply formatting to the text as you desire and save it back out as an RTF file.

Idle_Mind

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 29

Expert Comment

by:leonstryker
ID: 9906553
Test files do not support color fonts.  If you want colored text in your log file you should send it to a Word document, or Excel, or any other application which does.

Leon
0
 
LVL 1

Expert Comment

by:Moglor
ID: 9907110
if all you want to do is make errors more visible within a text file then i would put some distinguishing marks before and after the error message like this...

***Error Message Here***
or
###Error Message Here###

with plain text, in something like Notepad, there isnt any way to change the color or font of the text.
0
 
LVL 9

Expert Comment

by:malharone
ID: 9908510
why not export to an XML file ... which can be displayed using an XSD file..
for example, use Microsoft's Messenger, and log conversations. they save to an XML file ... which is displayed in full colors using the XSD files.

hope this helps
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 9909249
or export to html
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now