Option ExplicitDim BRUSH As BooleanPrivate Sub Command1_Click() BRUSH = True End SubPrivate Sub Form_Load() BRUSH = False Form1.AutoRedraw = True End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 And BRUSH = False Then Picture1.DrawWidth = 3 Picture1.PSet (X, Y), vbRed End If If Button = 1 And BRUSH = True Then Picture1.DrawWidth = 10 Picture1.PSet (X, Y), Picture1.BackColor End IfEnd Sub
Option Explicit Dim flag As Boolean Dim x1 As Integer '起点X坐标 Dim y1 As Integer '起点Y坐标 Dim x2 As Integer '终点点X坐标 Dim y2 As Integer '终点Y坐标 Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) flag = True x1 = X y1 = Y End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If flag = False Then Exit Sub End If If flag = True Then Picture1.DrawWidth = 16 '橡皮擦大小 x2 = X y2 = Y Picture1.Line (x1, Y)-(x2, y2), Picture1.BackColor x1 = x2 y1 = y2 End If End SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) flag = False End Sub
BRUSH = True
End SubPrivate Sub Form_Load()
BRUSH = False
Form1.AutoRedraw = True
End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 And BRUSH = False Then
Picture1.DrawWidth = 3
Picture1.PSet (X, Y), vbRed
End If
If Button = 1 And BRUSH = True Then
Picture1.DrawWidth = 10
Picture1.PSet (X, Y), Picture1.BackColor
End IfEnd Sub
Dim flag As Boolean
Dim x1 As Integer '起点X坐标
Dim y1 As Integer '起点Y坐标
Dim x2 As Integer '终点点X坐标
Dim y2 As Integer '终点Y坐标
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
flag = True
x1 = X
y1 = Y
End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If flag = False Then
Exit Sub
End If
If flag = True Then
Picture1.DrawWidth = 16 '橡皮擦大小
x2 = X
y2 = Y
Picture1.Line (x1, Y)-(x2, y2), Picture1.BackColor
x1 = x2
y1 = y2
End If
End SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
flag = False
End Sub