Drawing

This Tutorial will show you how to make a simple Drawing Package using a Picture Box on a Form.

www.cespage.com/vb/vbtut4.html

Step 1

Load Microsoft Visual Basic, then select Standard EXE Project if VB5/6, click on the option then click Open, see below:

New Project

Step 2

A Blank Form named Form1 should then appear, see below:

Form 1

Step 3

Then from the Visual Basic Components Menu Select the Picture Box Control:

Picture Box Control

Step 4

Draw a Picture Box on the Form, see below:

Form1 with Picture Box

Step 5

Then go to the Properties box and change the AutoRedraw Property to True, see below:

Properties

Step 6

Double Click on the PictureBox (Picture1) and type in the Picture1_MouseDown() Sub:

Picture1.CurrentX = X
Picture1.CurrentY = Y

Step 7

Double Click on the PictureBox (Picture1) and type in the Picture1_MouseMove() Sub:

If Button = 1 Then
  Picture1.Line (Picture1.CurrentX, Picture1.CurrentY)-(X, Y), vbBlack
End If 

Step 8

Save the Project (for example prjDrawing) into a vacant folder as you have finished the application. Click on Start / Run Start / Run or Press F5 and the below will appear:

Application Running

Step 9

Now place the Mouse Cursor over the Picture Box (the recessed area), press the Left Mouse Button and move it about, or try an write something, see below:

Drawing Hello World

Step 10

Just Click the X in the Corner and/or End / Stop End / Stop the application.

This is a very simple Drawing Package, Try changing the DrawWidth Property of the Picture Box to get a Thicker line, or the Colour by using another vbColour e.g. vbBlue or vbRed!