See Also Example
Applies To
Form, check box
Description
Determines the font used to display text in a control or in a run-time drawing or printing operation.
Usage
{ [form.][control.]|Printer.}FontName[ = font ]
Remarks
The default for this property is determined by the system. Fonts available with Visual Basic vary according to your system configuration, display devices, and printing devices. Font-related properties can be set only to values for which fonts exist.
In general, you should change FontName before setting size and style attributes with the FontSize
On systems running Windows 3.0, the fonts "Helv" or "Tms Rmn" are called "MS Sans Serif" and "MS Serif", respectively. In code, if you set FontName to "Helv," then test whether the FontName is set to "Helv," the result will be False, since it will be changed internally to "MS Sans Serif."
Note At run time, you can get information on fonts available to the system through the FontCount
Data Type
String
Help:
FontBold, FontItalic, FontStrikethru, FontTransparent, FontUnderline Properties
FontSize Property
Print Method
TextHeight Method
TextWidth Method
Programmer's Guide:
Chapter 16, "Displaying and Printing Information"
The example prints the name of each font using the particular font. To try this example, paste the code into the Declarations section of a form. Press F5 to run the program and then click the form. Each time you click the form, the font name is printed.
Sub Form_Click ()
Static I ' Declare variables.
Dim OldFont
OldFont = FontName ' Preserve original font.
FontName = Screen.Fonts(I) ' Change to new font.
Print Screen.Fonts(I) ' Print name of font.
I = I + 1 ' Increment counter.
If I = FontCount Then I = 0 ' Start over.
FontName = OldFont ' Restore original font.
End Sub