Simple Drawing Package
Learn to make a Simple Drawing Package using Visual Basic 6 with this Tutorial that Celebrates the CESPage 25th Anniversary
Well if you did the Drawing tutorial this is even better, which will introduce you to the ComboBox control along with using the PictureBox and Command Button controls.
Step 1
Step 2
Step 3
Step 4
Step 5
AutoRedraw to True, see below:
Step 6
Step 7
Step 8
Change the Style Property of both Combo Boxes of Combo1 and Combo2 to 2- Dropdown List.
Step 9
Step 10
Caption Property of the
Command Button to Quit
Step 11
Double Click on the Command Button labelled Quit or Command1 and type in the Command1_Click() Sub:
Unload Me
Step 12
Double Click on the Form of Form1 and type in the Form_Load() Sub:
With Combo1
.AddItem 1
.AddItem 2
.AddItem 4
.AddItem 8
.AddItem 16
.AddItem 32
.AddItem 64
End With
Combo1.ListIndex = 0
With Combo2
.AddItem "Black"
.AddItem "Red"
.AddItem "Green"
.AddItem "Blue"
.AddItem "White"
End With
Combo2.ListIndex = 0
Step 13
Double Click on the PictureBox of Picture1 and type in the Picture1_MouseDown() Sub:
Picture1.CurrentX = X
Picture1.CurrentY = Y
Step 14
Double Click on the PictureBox of Picture1 and type in the Picture1_MouseMove() Sub:
Dim Colour As String
If Button = 1 Then
Picture1.DrawWidth = Combo1.Text
If Combo2.Text = "Black" Then Colour = vbBlack
If Combo2.Text = "Red" Then Colour = vbRed
If Combo2.Text = "Green" Then Colour = vbGreen
If Combo2.Text = "Blue" Then Colour = vbBlue
If Combo2.Text = "White" Then Colour = vbWhite
Picture1.Line (Picture1.CurrentX, Picture1.CurrentY)-(X, Y), Colour
End If
Step 15
Step 16
Step 17
Great you have just created an improved Simple Drawing Package! Try changing the program so that other Draw Widths are available
(add more values to the With Combo1 List!) Plus add more colours by adding the new names e.g. Yellow and then
in the MouseMove Sub of the Picture Box add a conversion routine e.g. If Combo2.Text="Yellow" then Colour=vbYellow.
Try changing other parts of the code and extending it, you can learn a lot from this Simple Drawing Package!