Solved

Need help creating a class that draws circles on a picture box

Posted on 2002-04-26
2
138 Views
Last Modified: 2010-05-02
Please help me create a class that draws circles on a Picture Box.  The class should have a method called DrawCircle. If necessary, create properties.The User Interface will display circle(s) with different size and color indicated by user.
0
Comment
Question by:Gmoney
2 Comments
 
LVL 4

Accepted Solution

by:
gencross earned 100 total points
Comment Utility
Paste this code into a new class module named Class1:

Public Sub DrawCircle(PicBox As PictureBox, X As Single, Y As Single, Radius As Single, Optional vColor)
   
   Dim iXO As Integer
   Dim iYO As Integer
   
   Dim iFirstX As Integer
   Dim iFirstY As Integer
   Dim iLastX As Integer
   Dim iLastY As Integer
   
   iFirstX = X
   iFirstY = Y
   iLastX = X
   iLastY = Y
   
   iX0 = (iFirstX + iLastX) / 2
   iY0 = (iFirstY + iLastY) / 2
   
   PicBox.Circle (iX0, iY0), Radius, vColor 'Form1.Picture1.ForeColor 'vbRed

End Sub

Paste this code in a form with a picture box named Picture1:

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
   
    Dim objDraw As Class1
    Set objDraw = New Class1
   
    objDraw.DrawCircle Picture1, X, Y, 180, vbRed
   
End Sub

This code works fine.  If you need to add other parameters then add them to the call or you can convert the parameters to properties or public variables if you want, but I think this is the best solution.

Hope this helps.
0
 

Author Comment

by:Gmoney
Comment Utility
It works great, thanks for your help
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now