[AccessD] MSAccess HTML Textbox - part three - take two
John Colby
jwcolby at gmail.com
Tue Jul 26 07:49:48 CDT 2022
Let's try this again...
So 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 named txtTest
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.", , , , , ,
, "ALGERIAN"
'
'Formatted substrings strung together
'
mclsHTMLTestTextBox.fWriteRaw "We have test data ", False
mclsHTMLTestTextBox.fWriteRaw "ALGERIAN ", False, , , , , , "ALGERIAN"
mclsHTMLTestTextBox.fWriteRaw "BLUE.", , , , , , , , 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.
We have test data ALGERIAN BLUE.
The first thing to notice here is that I took the simple approach and
processed each string to be formatted as a unit. I am not versed in HTML
so I no doubt caused headaches if I want to apply formatting across
multiple strings. Think alignment center of strings. TBH I didn't get
alignment working in any form anyway. In fact so far the *only* things I
have working are simple stuff like fonts, colors bold etc. I will likely
come back to this in the future to try and add in missing parts.
One thing to notice is that if you click into the text box, the text
formatting in the toolbar allows you to do whatever you want, which is
cool. I'm going to discuss that a little further in the next email.
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