'use of commondialogbox

'1: choose printer
'2: choose font
'3: choose color


'1: choose printer
Public 

sub

ChoosePrinter Const ErrCancel = 32755 CommonDialog1.CancelError = True On Error GoTo errorPrinter CommonDialog1.Flags = 64 'see the

help

on Flags Properties (Print Dialog) CommonDialog1.ShowPrinter CommonDialog1.PrinterDefault = False

exit

Sub errorPrinter: If Err = ErrCancel Then

exit

sub

Else Resume End Sub '2: choose font Global vScreenFont, vScreenFontSize Public

sub

ChooseFont() CommonDialog1.Flags = cdlCFScreenFonts 'see the

help

on Flags Properties (Font Dialog) CommonDialog1.ShowFont vScreenFont = CommonDialog1.FontName vScreenFontSize = CommonDialog1.FontSize Call ChangeFont(Form1) End Sub Public

sub

ChangeFont(X

as

Form)

dim

Control For Each Control In X.Controls If TypeOf Control Is

label

Or _ TypeOf Control Is TextBox Or _ TypeOf Control Is CommandButton Or _ TypeOf Control Is ComboBox Or _ TypeOf Control Is ListBox Or _ TypeOf Control Is CheckBox Then Control.Font = vScreenFont Control.FontSize = vScreenFontSize

end

If Next Control End Sub '3: choose color Global vColor Public

sub

ChooseColor CommonDialog1.Flags = &H1& Or &H4& 'see the

help

on Flags Properties (Color Dialog) CommonDialog1.ShowColor vColor = CommonDialog1.Color ' if you

want

to convert the color to hex use ' MsgBox Convert2Hex(vColor) ' if you

want

to repaint youre background use ' Call ChangeColor(X

as

Form) End Sub Public

sub

ChangeColor(X

as

Form)

dim

Control X.BackColor = vColor For Each Control In X.Controls If TypeOf Control Is

label

Or _ TypeOf Control Is TextBox Or _ TypeOf Control Is CommandButton Or _ TypeOf Control Is ComboBox Or _ TypeOf Control Is ListBox Or _ TypeOf Control Is CheckBox Then Control.BackColor = vColor

end

If Next Control End Sub Public Function Convert2Hex(color)

as

String Dim RedValue, GreenValue, BlueValue RedValue = (color And &HFF&) GreenValue = (color And &HFF00&) \ 256 BlueValue = (color And &HFF0000) \ 65536 Convert2Hex = Format(Hex(RedValue) & Hex(GreenValue) & Hex(BlueValue), "000000") End Function
Return