FontBold, FontItalic, FontStrikethru, FontTransparent, FontUnderline Properties
See Also Example
Apply To
Form, check box
Description
Determine font styles in the following formats: FontBold, FontItalic, FontStrikethru, and FontUnderline. FontTransparent determines whether background text or graphics are included with the characters in a particular font; FontTransparent applies only to forms, picture boxes, and the Printer object.
Usage
{ [form.][control.]|Printer.}FontBold[ = boolean ]
{ [form.][control.]|Printer.}FontItalic[ = boolean ]
{ [form.][control.]|Printer.}FontStrikethru[ = boolean ]
{ [form.][picturebox.]|Printer.}FontTransparent[ = boolean ]
{ [form.][control.]|Printer.}FontUnderline[ = boolean ]
Setting
The settings for the FontBold, FontItalic, FontStrikethru, FontTransparent, and FontUnderline properties are:
Setting Description
True (Default for FontBold (except with the common dialog control) and FontTransparent) Turns on the formatting in that style. Setting FontTransparent to True permits background graphics or text to show through the characters in a font.
False (Default for FontItalic, FontStrikethru, and FontUnderline; and FontBold with the common dialog control) Turns off the formatting in that style. Setting FontTransparent to False masks out existing background graphics or text.
Remarks
Use these font properties to format text, either at design time using the Properties window or at run time using code. For forms, picture boxes, and the Printer object, setting these properties does not affect graphics or print output already drawn to a form, picture box, or Printer object. For all other controls, font changes take effect on the screen immediately.
To use these properties with the common dialog control, the CF_EFFECTS flag must be set.
Note Fonts available in Visual Basic vary according to your system configuration, display devices, and printing devices. Font-related properties can be set only to values for which actual fonts exist.
In general, you should change the FontName However, when you set TrueType fonts to smaller than 8 points, you should set the point size with the FontSize property, then set the FontName property, and then set the size again with the FontSize property. The Windows environment uses a different font for TrueType fonts that are smaller than 8 points.
Data Type
Integer (Boolean)
Help:
TextHeight Method
TextWidth Method
Programmer's Guide:
Chapter 16, "Displaying and Printing Information"
FontBold, FontItalic, FontStrikethru, FontTransparent, FontUnderline Properties Example
The example puts text on a form in one of two combinations of styles with each mouse click. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.
Sub Form_Click ()
FontStrikethru = Not FontStrikethru ' Toggle strikethru.
FontItalic = Not FontStrikethru ' Toggle font style.
Print "Now is the time!" ' Print some text.
End Sub