Re: write text streams in either bold face or red



The RTB control requires a license. There's a
version here that doesn't:
http://www.jsware.net/jsware/scripts.phi#jsrtb

That version is virtually the same thing. Both are
OCX wrappers for the Windows richedit DLL.

But the rich text approach seems like an awfully lot
of extra trouble to me. RichText *can* be constructed
relatively easily by hand. And it would be easier still to
just use HTML:

-------------------------------------
<HTML><HEAD>
<STYLE>
BODY {color: #000000; font-family: verdana; font-size: 13px;}
.RedText {color: #FF0000; font-weight: 700;}
</STYLE>
</HEAD>
<BODY>
<DIV ALIGN="left">


</DIV>
</BODY>
</HTML>
------------------------------

The above HTML is all that's needed to set up a page
that will display plain black text in Verdana font.
Just put all text inside the DIV tag and wherever
bold red text is desired put it between these two tags:

<SPAN CLASS="RedText"> bold red text here. </SPAN>

To make it only bold do this:

<B> bold text here</B>

That should be fairly simple to do with textstream.
(Also, line returns need to be added as <BR>.)

I've searched around for some postings on writing formatted text to
worpad but am coming up short. Do you know of any
postings/documentation on that.

You could use the Rich Text Control to create a WordPad document. You
should find it is installed by default with Windows XP. For older
systems that do not have it already, Microsoft provides it as a
redistributable.

Download details: Platform SDK Redistributable: Common Controls DLL

http://www.microsoft.com/downloads/details.aspx?FamilyID=6f94d31a-d1e0-4658-
a566-93af0d8d4a1e

The documentation for it can be found on Microsoft's website.

RichTextBox Control

http://msdn.microsoft.com/library/en-us/rtfbox98/html/vbobjRichEdit.asp?fram
e=true

An example that uses the control to implement a simple logging class
follows.

Option Explicit

Const LogPath = "test.rtf"

Dim log: Set log = New RtfLog
Dim stream: Set stream = CreateObject("ADODB.Stream")

' Record some audit results
log.Pass "Audit 1"
log.Fail "Audit 2"
log.Pass "Audit 3"

' This works for EN-US, but will probably need to be changed for other
' locales. I didn't see any obvious way to make the Rich Text Control
just
' use Unicode instead.
stream.Charset = "latin1"

' Copy the log to the stream object
stream.Open
log.Save stream

' Write the stream object to disk
stream.SaveToFile LogPath

Class RtfLog
' Log a passed audit
Function Pass(msg)
rtf.SelColor = PassColor
rtf.SelText = "PASS" & vbTab & msg & vbNewLine
End Function

' Log a failed audit
Function Fail(msg)
rtf.SelColor = FailColor
rtf.SelText = "FAIL" & vbTab & msg & vbNewLine
End Function

' Write the document to an ADO Stream object
Function Save(stream)
stream.WriteText rtf.TextRTF
End Function

Private rtf, PassColor, FailColor
Private Sub Class_Initialize
Set rtf = CreateObject("RICHTEXT.RichtextCtrl")
rtf.SelStart = 0
rtf.SelHangingIndent = Twips(.5)

PassColor = vbBlack
FailColor = vbRed
End Sub
End Class

' Convert a length given in inches to twips
Function Twips(inches) : Twips = CLng(inches*1440) : End Function


--
Justin Piper
Bizco Technologies
http://www.bizco.com/


.



Relevant Pages

  • Re: write text streams in either bold face or red
    ... An example that uses the control to implement a simple logging class ... ' Record some audit results ... ' Copy the log to the stream object ... Private rtf, PassColor, FailColor ...
    (microsoft.public.scripting.vbscript)
  • Re: VB Functions Dont Work with Workgroup Security
    ... This information is then transferred into an audit table. ... Public Sub AuditTrail(KeyFieldName As String, KeyFieldValue As String, ... Dim c As Control, xName As String ... record it in audit trail and exit sub. ...
    (comp.databases.ms-access)
  • Re: SAS 70
    ... Can anyone provide me with some pointers on SAS 70 auditing? ... this type of audit. ... control framework in place, ...
    (Pen-Test)
  • Re: A small problem comparing types
    ... Each audit control is a descendant ... I've tried to make a fake instance of an AuditableTextControl and then ... > tried to get the type of that, but that doesnt work either. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A small problem comparing types
    ... Each audit control is a descendant ... I've tried to make a fake instance of an AuditableTextControl and then ... > tried to get the type of that, but that doesnt work either. ...
    (microsoft.public.dotnet.framework)