Professional Documents
Culture Documents
Color ShowColor
'Assign dialog box color to the form
Font ShowFont frmMain.BackColor = dlgCommon.Color
Print ShowPrint End Sub
Color Dialog Box
Answer 1
Answer 2
End With
End Sub
Font Dialog Box
• Before you can use the ShowFont method, you must set the Flags property of the
control – to install the fonts to appear in the list box.
• If you forget to set the flags, an error will occur at run time that says “There are no fonts
installed”.
• The value of the Flags property may be cdlCFScreenFonts, cdlCFPrinterFonts, or
cdlCFBoth.
• The Font properties for the common dialog control are different from those used for
other controls.
Font Object of Font Property of Values Private Sub mnuEditFont_Click()
Other Controls Common Dialog
Control 'Display the Font dialog box
With dlgCommon
Font.Bold FontBOld True/False .Flags = cdlCFScreenFonts
To open the Font dialog
.ShowFont box on the screen
Font.Italic FontItalic True/False End With
Font.Name FontName System dependent
'Assign dialog box font to the label
Font.Size FontSize Font dependent With lblMessage.Font
.Name = dlgCommon.FontName
Font.StrikeThrough FontStrikeThru True/False .Bold = dlgCommon.FontBold
End With
Font.Underline FontUnderline True/False End Sub
Setting Current Values
• Before calling the common dialog box for colors or fonts, you should assign the
existing values of the object properties that will be altered.
• This step will provide for the display of the current values in the dialog box.
• It also ensures that if the user selects the Cancel button, the property settings
for the objects will remain unchanged.
• When you pass a value to a procedure you may pass it ByVal or ByRef (for
by value or by reference).
• The ByVal sends a copy of the argument’s value to the procedure so that
the procedure cannot alter the original value.
• The ByRef sends a reference indicating where the value is stored in
memory, allowing the called procedure to actually change the argument’s
original value.
• You can specify how you want to pass the argument by using the ByVal or
ByRef keyword before the argument.
• If you don’t specify ByVal or ByRef, arguments are passed by reference.
Example: Create a function procedure called Commision, which calculates and returns a
salesperson’s commission. <follow the same step as for creating a sub procedure. But, select the
Function option button prior to selecting the OK command button>.
Private Function Commision( ) Private Sub Commision( )