Share via


Visual Basic Reference

FontName Property Example

This 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.

  Private 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