VB6 - Updated Paint Tutorial

All tutorials created in VB6 to be posted in here.
6 posts Page 1 of 1
Contributors
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

VB6 - Updated Paint Tutorial
GoodGuy17
Hello,
This tutorial assumes you have a basic knowledge of Visual Basic 6 and have made a few apps with it.
I am going to tell you how to make a more advanced painting application in Visual Basic 6.
This time it will be easier to follow as I will use my Step-By-Step thing.
NOTE: To make this painting application, you must NOT have Visual Basic 6 Portable. VB6 MUST be installed.
Here we go:
1. Open VB6 and create a new Standard Exe project.
2. Resize your form and rename it.
3. Add the following:
1 Picturebox - Name: Paint Appearance: 0-Flat
3 Buttons - Names: cmdColor, cmdSize, cmdExit Captions: Color, Size, Exit
1 Commondialog control
4. Now all we need is the code! Here it is:
Code: Select all
Dim Drawing As Boolean

Private Sub cmdColor_Click()
CommonDialog1.CancelError = True
CommonDialog1.Flags = CC_RGBINIT Or CC_FULLOPEN
CommonDialog1.Action = 3
Paint.ForeColor = CommonDialog1.Color
End Sub

Private Sub cmdExit_Click()
End
End Sub

Private Sub cmdSize_Click()
Dim strSize
strSize = InputBox("Enter a value.")
Paint.DrawWidth = strSize
End Sub

Private Sub Form_Load()
Drawing = False
End Sub

Private Sub Paint_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Drawing = True
Paint.CurrentX = X
Paint.CurrentY = Y
End Sub

Private Sub Paint_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Drawing = True Then
Paint.Line -(X, Y), Paint.ForeColor
End If
End Sub

Private Sub Paint_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Drawing = False
End Sub
5. That's it! 5 easy steps! Run your program, and if it works you are a good reader!
Enjoy!
~GoodGuy17~ :D
User avatar
Marfie
Just Registered
Just Registered
Posts: 1
Joined: Sat Oct 09, 2010 8:24 pm

Re: VB6 - Updated Paint Tutorial
Marfie
Nice work =]
User avatar
riottechtalk
New Member
New Member
Posts: 11
Joined: Sat Feb 19, 2011 4:12 am

great job
User avatar
shalini yadav
Just Registered
Just Registered
Posts: 1
Joined: Tue Sep 27, 2011 1:56 pm

this is really nice......but i need to insert shapes in it ...
like circle or square or anything else...so can you please help me out with this ???
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Re: VB6 - Updated Paint Tutorial
GoodGuy17
Sorry, I'm not sure how to do this, I haven't used VB6 in quite awhile.

(sorry for bump)
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: VB6 - Updated Paint Tutorial
mandai
This article shows how to draw circles and rectangles in VB6: http://msdn.microsoft.com/en-us/library ... s.80).aspx
6 posts Page 1 of 1
Return to “VB6 Tutorials”