Solved

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

Posted on 2002-04-26
2
140 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

825 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