vb颜色对话框

来源:百度知道 编辑:UC知道 时间:2024/06/23 16:39:23
我写了一段用作图的代码~但为什么在弹出颜色框那里的代码出错了~我也不明白~我是菜鸟~请各位高手指教

Option Explicit
Dim x0, y0 As Integer

Private Sub Combo1_Click()
Picture1.DrawWidth = Val(Combo1.Text)
End Sub
Private Sub Command1_Click()
commondialog1.showcolor
Picture1.ForeColor = commondialog1.Color
End Sub

Private Sub Command2_Click()
Picture1.Cls
End Sub

Private Sub Form_Load()
Dim i As Integer
For i = 0 To 9
Combo1.AddItem Str(i + 1), i
Next i
Picture1.AutoRedraw = True
Picture1.Cls
Picture1.ForeColor = vbWhite
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Picture1.Line (x0, y0)-(X, Y)
End If
x0 = X: y0 = Y
End Sub

很简单,你没有添加commondialog控件在窗体上,或者你添加了,但是名字不是commondialog1 ,不然的话:commondialog1.showcolor 这句就不会全部是小写字母了!

刚刚测试了一下,没有问题,有其他的问题可以留言,或+qq 10148882