试试
Dim p As WinForm.Painter = e.Form.Controls("Painter1")
Dim g As Graphics = p.Graphics
If Vars("n") = 1 Then
If e.Button = MouseButtons.Left Then
points.add(New Point(e.x,e.y))
Vars("n")=Vars("n")+ 1
End If
ElseIf Vars("n") = 2 Then
If e.Button = MouseButtons.Left Then
points.add(New Point(e.x,e.y))
End If
End If
If Vars("n") = 2 Then
Dim point() As point = points.ToArray()
g.DrawLine(Pens.Red,point(0).x,point(0).y ,point(1).x ,point(1).y)
p.repaint()
points.clear()
Vars("n") = 1
End If