This code will allow you to have a popup color selector in your
app.
Start a new project and add the MS Common Dialog Control and
a
command button. Then cut and paste the code
below.
====================================================================
Private
Sub Command1_Click()
' The following line says: if the user will press the
cancel Button,
' treat it like if an error occurred in the
program.
CommonDialog1.CancelError = True
' If an error occurred in the
program, jump to the
' CancelPressed part of the program, below.
On
Error GoTo CancelPressed
' Pop up the Color
Selector
CommonDialog1.ShowColor
' Paint the from with the chosen
color.
' CommonDialog1.Color holds the color that the user has
selected.
Form1.BackColor = CommonDialog1.Color
' exit the
Command1_Click() sub
Exit Sub
CancelPressed:
' If the user pressed the
cancel button an error was occurred, and
' the program had jumped to
here.
' if the user didn't press the cancel button, the program doesn't apply
this
' lines because it already has exited this sub from the "Exit Sub" line
above
MsgBox "You pressed Cancel"
End Sub