Visual Basic Programming Code Examples Visual Basic > Graphics Games Programming Code Examples Creating a Freehand Drawing Tool Creating a Freehand Drawing Tool 'Variables used for the drawing tool. Dim Drawing As Boolean Dim FHLastX As Long Dim FHLastY As Long Private Sub Picture1_MouseDown(Button As Integer, _ Shift As Integer, X As Single, Y As Single) 'Specify that we are drawing now. Drawing = True 'Start where the mouse cursor is. FHLastX = X FHLastY = Y End Sub Private Sub Picture1_MouseMove(Button As Integer, _ Shift As Integer, X As Single, Y As Single) 'This is the technique we are using to 'draw freehand decently. Instead of drawing each point, 'we join the points up with lines. This is required as the 'MouseMove event will not fire on every pixel. Picture1.Line (FHLastX, FHLastY)-(X, Y) FHLastX = X FHLastY = Y End Sub Private Sub Picture1_MouseUp(Button As Integer, _ Shift As Integer, X As Single, Y As Single) 'Stop drawing. Drawing = False End Sub