HI all,


I want to know the result of common dialog control. My code is :

CommonDialog1.Flags = cdlCCFullOpen
CommonDialog1.ShowColor
Label1(0).BackColor = CommonDialog1.color

But i want to assing CommonDialog1.color value to label1(0).backcolor only if user click ok button of commondialog control if user click cancel button then default color is assign to that label.

Please can anybody help me for finding result of commondialog control.

I used this code also
dim result as DialogResult
result= commondialog1.showcolor

but it is giving error.

Please somebody help me.
Thanks in advance

Regards
guest11

Private Function GetColor(DefaultColor)
On Local Error GoTo GetColorError
CommonDialog1.CancelError = True
CommonDialog1.Flags = cdlCCRGBInit
CommonDialog1.Color = DefaultColor
CommonDialog1.ShowColor
GetColor = CommonDialog1.Color
Exit Function
GetColorError:
'User clicked the Cancel button
GetColor = DefaultColor
End Function

You need to set the Cancel Property of the the Common Dialog Control to True. If you do this, then an error will be generated with a value of 32755 whenever the user clicks on cancel.

Just set up error checking code

Private Sub Command_Click()
   On error goto Click_ERROR



   exit sub
Click_ERROR:
  If err.number = 32755
      ' Enter code to do whatever you want
  Else
      ' Do whatever
  End if

End Sub

SCBW had a good post. But this is just another way to deal with the problem. Make sure you enable the cancel error property.

CommonDialog1.CancelError = True

That's the main point. Set that. Then deal with the error code.

Hank

This article has been dead for over six months. Start a new discussion instead.