[AccessD] MSAccess HTML Textbox - part three

John Colby jwcolby at gmail.com
Tue Jul 26 01:57:14 CDT 2022


So, assuming moderator intervention... we have a pair of classes.
clsHTMLFormat processes a single string needing formatting.  clsHTMLTextBox
wraps the text box, providing a collection to store the instances of
clsHTMLFormat as they are created, initialization stuff and a function to
create instances of clsHTMLFormat, passing in the string and some booleans
(mostly) which say "apply xyz formatting thing" if true.

The final piece is to discuss setup in the form which holds the text box.

Build a form.  Insert a text box in it.

Option Compare Database
Option Explicit

Dim mclsHTMLTestTextBox As clsHTMLTextBox

Private Sub Form_Load()
    Set mclsHTMLTestTextBox = New clsHTMLTextBox   'High level licensing
status
    mclsHTMLTestTextBox.Init Me, txtTest
    mclsHTMLTestTextBox.fWriteRaw "We have test data BOLD.", , True
    mclsHTMLTestTextBox.fWriteRaw "We have test data ITALICS.", , , True
    mclsHTMLTestTextBox.fWriteRaw "We have test data UNDERLINE.", , , , True
    mclsHTMLTestTextBox.fWriteRaw "We have test data BIG.", , , , , 5
    mclsHTMLTestTextBox.fWriteRaw "We have test data RED.", , , , , , "RED"
    mclsHTMLTestTextBox.fWriteRaw "We have test data ALGERIAN BLUE.", , , ,
, , , "ALGERIAN", enumVBColors.Blue
End Sub

The results look like this:

We have test data BOLD.

We have test data ITALICS.

We have test data UNDERLINE.

We have test data BIG.

We have test data RED.

We have test data ALGERIAN BLUE.


The takeaway here is that:
1) Ya gotta be careful about the formatting of lines in an email 😝
2) Classes can actually be useful
3) Classes given away by folks can be easy to pull in and use in your own
projects

Seriously though, There is a whole lot of "I don't use classes because...
yada yada no inheritance.  Try to implement this functionality without
classes.  We'll talk when you have no hair left.

And finally, in my error handlers I use the following to allow me to turn
on and off debug.print for a module or for the entire project.  Put that in
a module and it can be called if needed.

Public Sub assDebugPrint(ByVal vstrMsg As String, _
                            Optional DebugPrint As Boolean = True, _
                            Optional boolStop As Boolean = False)
#If DebugPrint Then
  If DebugPrint = True Then Debug.Print vstrMsg
  If boolStop Then Stop
#End If
End Sub

Feedback welcome.
-- 
John W. Colby
Colby Consulting


More information about the AccessD mailing list