Dim X1, Y1, X2, Y2 As Integer Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown X1 = e.X Y1 = e.Y End Sub Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp X2 = e.X Y2 = e.Y Dim g As Graphics = AutoGraphics(PictureBox1) g.DrawLine(dpen, X1, Y1, X2, Y2) End If End Sub Public Function AutoGraphics(ByVal picSource As PictureBox) As Graphics If picSource.Image Is Nothing Then picSource.Image = New Bitmap(picSource.ClientRectangle.Width, picSource.ClientRectangle.Height) End If Return Graphics.FromImage(picSource.Image) End Function