I am able to get my font and color dialog to open and change to what ever I
want. The code I am using is something like (below). The problem is when I
hit the cancel button the property of the object will display. For example,
if I hit cancel on the backgroud color it will turn black because the default
color for the dialog is blk. I have tried to do something like (next below)
and when I do that it is still calling the default color. What is the best
way to write for a color dialog? How do I handle the cancel button?
sub
with dlgcolor
.showcolor
rtbcolor = color
end with
dim something as dialogresults
if something <> dailogresults.OK then
rtbcolor = color
end if
Mike TomlinsonMiddle School Assistant TeacherCommented:
Private Sub Command1_Click()
On Error GoTo cancelled
CommonDialog1.CancelError = True
CommonDialog1.ShowColor
RichTextBox1.SelColor = CommonDialog1.Color
cancelled:
End Sub
Mike TomlinsonMiddle School Assistant TeacherCommented:
So sorry:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If ColorDialog1.ShowDialog = DialogResult.OK Then
RichTextBox1.SelectionColor = ColorDialog1.Color
End If
End Sub
~IM
0
freebird317Author Commented:
That is what I got by when I cancel it is erroring out on me. Oh well at least it is Saturday so I can play work on it today. : )
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.
On Error GoTo cancelled
CommonDialog1.CancelError = True
CommonDialog1.ShowColor
RichTextBox1.SelColor = CommonDialog1.Color
cancelled:
End Sub