Important alert: (current site time 7/16/2013 1:30:46 AM EDT)
 

VB icon

**Area Of Circle Calculator**

Email
Submitted on: 6/6/1999
By: Brady Botkin  
Level: Not Given
User Rating: By 8 Users
Compatibility: VB 5.0, VB 6.0
Views: 65590
 
     This code allows the user to find the area of circle by clicking a command button and then typing in the radius of the circle. It is very helpful to anyone working on a calculator project. I am also coming out with area of triangle and square.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: **Area Of Circle Calculator**
' Description:This code allows the user to find the area of circle by clicking a command button and then typing in the radius of the circle. It is very helpful to anyone working on a calculator project. I am also coming out with area of triangle and square.
' By: Brady Botkin
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1989&lngWId=1'for details.'**************************************

' Step 1. Place a command button in your form and name it Command1 and make the 
'caption Area Of A Circle.
' Step 2. Copy this code into the form...
Private Sub Command1_Click()
 
 Dim Radius
 Radius = InputBox("Type In The Radius", "Radius")
 Dim Area
 Area = 3.14 * (Radius * Radius)
 MsgBox Area, vbDefaultButton1, "Answer"
 
 Dim Answer
 
 
End Sub


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

8/28/1999 7:23:00 AMMikeal

Nice Work :>
(If this comment was disrespectful, please report it.)

 
1/18/2000 7:06:05 PMDP

This code is a bit sloppy(I doubt that it will even work), let me show you how to properly take care of this...

Const Pi = 3.1428571

Private Sub Command1_Click()
'Sets aside memory
Dim Radius As Integer
Dim Area As Integer

'Gets user input
Radius = Int(InputBox("What is the radius?", "Your Radius"))

'Calculates the area
Area = Pi * (Radius * Radius)

'Informs the user of the result
MsgBox "The area of this circle is " & Area & " square units.", vbInformation, "Your Area"
End Sub

If you have any qustions, e-mail me at xenyx@hotmail.com

(If this comment was disrespectful, please report it.)

 
2/4/2000 8:48:12 AMWes

DP: Your code is even worse.

You got PI wrong (try 3.14159) and you're using integers for everything. Integers only hold whole numbers . . .
(If this comment was disrespectful, please report it.)

 
8/7/2000 6:17:26 PMThe Phantom

HiJueLA!!!
(If this comment was disrespectful, please report it.)

 
10/10/2000 1:06:53 PMThinh

Private Sub Command1_Click()
Radius = InputBox("Type In The Radius", "Radius")
Area = 3.14159265358979 * (Radius * Radius)
MsgBox Area, vbDefaultButton1, "Answer"
End Sub
(If this comment was disrespectful, please report it.)

 
10/10/2000 4:20:35 PMPhoenixX_2

Hey Brady, why don't you just stop floding PSC with this math stuff. Just put it all in one code. And maybe put them into Functions so it looks nicer?
And start putting AS's! As Single is much better than nothing at all. Since VB will just make the variable a Variant which takes more memory. Plus, make PI into a Dim in the actual form (or a public) so it doesn't have to keep re-entering. Or even better a public const.

Just little tips, and nothing more.
(If this comment was disrespectful, please report it.)

 
10/28/2000 11:14:22 PMVeeJay

Try this. It looks nicer

Const Pi = 3.14159265358979

Private Function Area(Radius as Long) As Long
Area = Pi * Raius ^ 2
End Function

Doesn't that look nice and usable in a module. Just change Private with Public.

Later
VeeJay
(If this comment was disrespectful, please report it.)

 
10/28/2000 11:16:12 PMVeeJay

... and change Raius with Radius :)
(If this comment was disrespectful, please report it.)

 
12/6/2000 6:22:53 PMJapeth Starlite

Pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803 4825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622 94895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664
...a nd
more...but i don't care so stop arguing!
(If this comment was disrespectful, please report it.)

 
12/18/2000 7:56:48 PMVs

This whole code is a waste, I have made mine more simpler and it is graphical too..
(If this comment was disrespectful, please report it.)

 
5/2/2001 2:42:16 AMra2fan

Hey can any one help me with this?
(If this comment was disrespectful, please report it.)

 
10/6/2001 8:32:12 AMScott Coker

I like the thought of the program. I can't find many programs out there that deal with math. Can you figure out how to make it work with two text boxes and where the answer will be in the third one.Please Reply spcoker@bellsouth.net

(If this comment was disrespectful, please report it.)

 
12/12/2001 6:08:29 AMKyle mathers

the code needs work as everybody has pointed out but have failed to format it you could end up with an answer with 15 decimals as a double or more as a long
This is the format code that VB5 gives but i have not been able to work it yet

Format(Var1, "#,##0.00")
formats 1000.678 to 1,000.68 i belive
(If this comment was disrespectful, please report it.)

 
12/22/2001 1:37:13 PMAlex Jestin Taylor

Yeah the code needs loads of revisions but what about when thhe user hits cancel and the program fails it looks really bad. whats the code to fix that?

(If this comment was disrespectful, please report it.)

 
1/3/2002 1:41:45 PMPsiko

Why have a whole program dedicated to such as simple function? I agree with Phoenix. Either make a program (or a module) with lots of simple functions, or a program to demonstrate a complicated function.
(If this comment was disrespectful, please report it.)

 
1/30/2002 1:26:00 PMRob Loach

You guys are lacking skill and knowledge.
(If this comment was disrespectful, please report it.)

 
5/18/2002 12:54:29 AMBrad Savon

How about you DRAW a circle and make a line to the center of it. Then you put a frame above the line and name it Radius and a text box in it name txtRad. Then put two frames with textboxes on the left side of the form and name them txtCirumference and txtArea. Put a Command button under it and put this code in:
Private Sub Command1_Click()
Const Pi = 3.14159
txtArea.Text = Pi * Val(txtRad.Text) ^ 2
txtCir.Text = Pi * Val(txtRad.Text * 2)
End Sub
LOOKS GREAT and Better than any of these other codes. Make this or download my calculator. Brad's Calculator
(If this comment was disrespectful, please report it.)

 
6/11/2002 9:24:42 PMsmackypete

pi= 4 * Atn(1)
(If this comment was disrespectful, please report it.)

 
9/21/2002 7:53:38 PMTi_fran

I can't understand so many people vote for tour code , there's nothing special.
(If this comment was disrespectful, please report it.)

 
1/31/2003 3:22:46 PM

How bout this??


Private Sub Command1_Click()
Dim rad As Integer
Dim ans As Integer
rad = Text1.Text
ans = 3.14 * (rad ^ 2)
MsgBox " Answer: " & ans & " "
End Sub
(If this comment was disrespectful, please report it.)

 
2/3/2003 5:13:31 AM

your program are good. i hope u can developed more programs and shared it. more power to you...
(If this comment was disrespectful, please report it.)

 
3/1/2003 1:05:50 AM

You guys, this person that developed this code probably is just a kid, but that is still merely an assumption. The main point is if you are going to get real picky over something mathematical, at least the topic should be challenging so we all benefit from all other people's intelligence in their approach to solving a problem. For instance, why don't we try to graph the Folium of Descartes: x^3 + y^3 = 6xy. Any ideas on how to solve that and show a graph of it? I surely don't have the answer to that one, but makes an interesting topic at least!
(If this comment was disrespectful, please report it.)

 
3/22/2003 2:04:33 AMNathan Masters

>>
Pi =
3.14159265358979323846264338327950288419
7169399375105820974944592307816406286208
9986280348253421170679821480865132823066
4709384460955058223172535940812848111745
02841027 01938521105559644622948954930381
9644288109756659334461284756482337867831
65271201909145648566 92346034861045432664

...and
more...but i don't care so
stop arguing!
<<

The point is pretty moot on this one, since no vb data type is even close to being this precise.

(If this comment was disrespectful, please report it.)

 
7/7/2003 3:25:51 PM

Instead of putting in the decimal why not put in the faction? You get the whole lot then. The fration is 22/7
(If this comment was disrespectful, please report it.)

 
9/22/2003 4:39:49 AMKalyana Kumar

Nice code Brady.I adore your initiative.Eventhough just few line of code,you upload it for all of us to share.Keep it up.We are into knowledge sharing yah.
(If this comment was disrespectful, please report it.)

 
2/12/2004 8:34:42 PM

the code is pretty good but will the author try do to something which is more benefit for the beginer........^^
(If this comment was disrespectful, please report it.)

 
10/11/2004 3:34:30 AM

thanks
(If this comment was disrespectful, please report it.)

 
11/6/2004 7:06:31 AM

lol happen to browse through this code
why not just use 22/7 as pi -.- ??
(If this comment was disrespectful, please report it.)

 
11/14/2004 3:18:11 PMRyan Palmer

Because 22/7 is not Pi, its just a very vague approximation. I thnk it gets 2 of the infinite decimal places correct
(If this comment was disrespectful, please report it.)

 
1/30/2007 6:07:11 AMchetanwagh

hi chetan sir
(If this comment was disrespectful, please report it.)

 
1/30/2007 6:14:18 AMchetanwagh

cdfdkfjla
(If this comment was disrespectful, please report it.)

 
5/19/2008 7:50:40 AMsoya lang ka yotch

bisaya imong prog haw dya ....
(If this comment was disrespectful, please report it.)

 
6/12/2009 9:52:35 AMchiu_ying2

that is really helpful. Thanks a lot.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.