Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2002-04-26
2
Medium Priority
?
146 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 400 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

715 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