Ask the MultiValued Visual
Basic Expert - #15
(as published in Spectrum
magazine Sep/Oct 1999)
To email your questions to "Ask the MultiValued VB
Expert", click here.
Copyright © 1996-99 Caduceus Consulting. All rights reserved.

Non-proportional Fonts
Dear MV/VB Expert:
If I capture the output of a report from the
host and then place the results in a text box, the report is not
formatted. If I use the fonts Terminal or System the report looks
O.K.
If I highlight part of the report and try to
change the font, the columns get corrupted (out of alignment). Is
there any way to convert the captured text to a specific TrueType
font before displaying? If that is possible, further manipulation
of the text would not corrupt the column spacing. - S.
Schwartz, Triple Creek Software
Yes, it is possible to manipulate fonts. As you
know, TCL uses spaces to line up columns in output. When the same
text is displayed in a proportional font, you lose the column
alignment. You are correct that "Terminal" and
"Fixedsys" are both non-proportional fonts that you can
select for the FontName property of the text box. The columns
will also line up if you select "Courier New", which is
a TrueType non-proportional font. You can change the font of a
text box on-the-fly in program code by altering its FontName
property:
Text1.FontName
= "Courier New"
Note that you are not converting the captured
text (which is simply an ASCII string) in any way, you are simply
changing the properties of the text box used to display the
captured text. Also note that if you are only displaying the
captured text and it does not need to scroll and such like, it
may be more appropriate to use a label control. Or better yet, a
text box with the Locked property set to True would allow the
user to scroll, select, and copy the text but not change it - you
decide which would be best. I hope this answers your question.

To email your questions to "Ask the MultiValued VB
Expert", click here.
Copyright © 1996-99 Caduceus Consulting. All rights reserved.
Added: August 18, 1999.
Return to Caduceus Consulting Home Page