Important alert: (current site time 12/20/2014 6:48:43 AM EDT)
 

VB icon

[ A program to calculate the area, circumference and diameter of a circle. ] UPDATED!!!

Email
Submitted on: 8/5/2003 5:27:26 AM
By: JamesJD  
Level: Beginner
User Rating: By 3 Users
Compatibility: VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 38131
author picture
(About the author)
 
     This simple little program will calculate the area, circumference and the diameter of a circle. If the user has entered a non numeric character it will inform them. Please leave your comments and votes, thanks :)

 
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: [ A program to calculate the area, circumference and diameter of a circle. ] UPDATED!!!
' Description:This simple little program will calculate the area, circumference and the diameter of a circle. If the user has entered a non numeric character it will inform them. Please leave your comments and votes, thanks :)
' By: JamesJD
'
' Inputs:One TextBox, one CommandButton, and three Labels. (You just need to keep their default names).
'
' Returns:The values of a circles area, circumference and diameter.
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=47415&lngWId=1'for details.'**************************************

Private Sub Command1_Click()
If Text1.Text = "" Then
 MsgBox ("Please enter a number in the text box!")
 Text1.SetFocus
Else
 If IsNumeric(Text1.Text) = False Then
MsgBox ("Please enter a numeric value!")
Text1.Text = ""
Text1.SetFocus
 Else
Dim Radius
 Radius = Text1.Text
Dim Diameter
 Diameter = Val(Radius) + Val(Radius)
Dim Area
 Area = 3.14159 * (Radius * Radius)
Dim Circumference
 Circumference = 3.14159 * (Val(Radius) + Val(Radius))
Label1.Caption = "Diameter: " & Diameter
Label2.Caption = "Area: " & Area
Label3.Caption = "Circumference: " & Circumference
Text1.Text = ""
Text1.SetFocus
 End If
End If
End Sub


Other 21 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 Beginner 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

5/15/2010 7:52:59 PMcan u help me plz

you are required to design a program that calculates the volume/ surface area of 3-D shapes as well as area/perimeter of 2-D shapes of some selected objects based on user’s choice.
The program should allow the user to pick the shape from a list. Available 2-D shapes are (square, rectangle, triangle, circle, rhombus, parallelogram) while available 3-D shapes are (cube, rectangular 3-D box, cone, sphere, cylinder). Upon shape selection, the user has to be asked to enter the appropriate data to calculate either the area/perimeter or the volume/surface area. The program has to be as robust as possible for different errors in data entered by the user like letters instead of numbers, negative numbers…etc
(If this comment was disrespectful, please report it.)

 
5/15/2010 7:54:02 PMcan u help me plz

and The project should have a welcome screen that shows the team names as well as some introductory information about the program. It should also have login fields asking for a user name and a password. In addition to that, the ability to change the password to a new one should be available to those users entering correct user names and old passwords. The password has to be formed of 5 characters with at least one number.
thnx
(If this comment was disrespectful, please report it.)

 
8/5/2011 2:23:52 AMNjoroge

So far so good
(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.