Page 1 of 1

VB6 - Updated Paint Tutorial

Posted: Tue Nov 03, 2009 2:45 am
by 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

Re: VB6 - Updated Paint Tutorial

Posted: Sat Oct 09, 2010 9:26 pm
by Marfie
Nice work =]

Re: VB6 - Updated Paint Tutorial

Posted: Tue Mar 08, 2011 9:29 am
by riottechtalk
great job

Re: VB6 - Updated Paint Tutorial

Posted: Tue Sep 27, 2011 2:24 pm
by shalini yadav
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 ???

Re: VB6 - Updated Paint Tutorial

Posted: Wed Oct 12, 2011 2:05 am
by GoodGuy17
Sorry, I'm not sure how to do this, I haven't used VB6 in quite awhile.

(sorry for bump)

Re: VB6 - Updated Paint Tutorial

Posted: Wed Oct 12, 2011 11:35 am
by mandai
This article shows how to draw circles and rectangles in VB6: http://msdn.microsoft.com/en-us/library ... s.80).aspx