Font dialog box: – The common dialog control also provide facility for changing font, font style and its size using font dialog box. The showfont method is used with name of common dialog control to show font dialog box. Syntax of the show font method is –

                <Control Name>.ShowFont

The font dialog box allows the user to select a font, font style and size. Our system has two types of fonts such as screen font and printer font. Before we can display the font dialog box, we must have specified which set of fonts we want displayed. We do this by setting the common dialog controls flag property. Common dialog control provides three different types of intrinsic constant with flag property. They are cdlCFScreenFonts, cdlCFPrinterFonts and cdlCFBoth. The intrinsic constant cdlCFScreenFonts is used for display only screen font in the font dialog box. The intrinsic constant cdlCFPrinterFonts is used to display only printer font with font dialog box. And the intrinsic constant cdlCFBoth is used for both printer and screen font with font dialog box.

If we fail to set the flags property to one of these intrinsic constant, a run time error will occur and the error message “There is no font installed” will be displayed.

We retrieve the font value selected by the user with help of fontname, fontbold, fontitalic, fontsize. The values we retrieve from these common dialog properties may be stored in the following properties of a label, text box or other control. An example of the font dialog box is as follows –

    DLGCommon.Flags = cdlCFScreenFonts
    With LBLMessage
        .Font.Name = DLGCommon.FontName
        .Font.Bold = DLGCommon.FontBold
        .Font.Italic = DLGCommon.FontItalic
        .Font.Size = DLGCommon.FontSize
    End With