Solved

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

Posted on 2002-04-26
2
139 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
ID: 6972797
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
ID: 6974023
It works great, thanks for your help
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

914 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

13 Experts available now in Live!

Get 1:1 Help Now