Solved

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

Posted on 2002-04-26
2
143 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

617 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