Important alert: (current site time 4/19/2014 2:36:34 AM EDT)
 

VB icon

[ A program to calculate the area, perimeter and radius of a square. ]

Email
Submitted on: 8/5/2003 5:05:31 AM
By: JamesJD  
Level: Beginner
User Rating: By 1 Users
Compatibility: VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 25093
author picture
(About the author)
 
     This simple little program will calculate the area, perimeter and radius of a square. Please leave you 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, perimeter and radius of a square. ]
' Description:This simple little program will calculate the area, perimeter and radius of a square. Please leave you 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 squares area, perimeter and radius.
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=47413&lngWId=1'for details.'**************************************

Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox ("Please enter a number in the text box!")
Text1.SetFocus
Else
Dim Length
Length = Text1.Text
Dim Radius
Radius = Length / 2
Dim Area
Area = Length * Length
Dim Perimeter
Perimeter = Val(Length) + Val(Length) + Val(Length) + Val(Length)
Label1.Caption = "Radius: " & Radius
Label2.Caption = "Area: " & Area
Label3.Caption = "Perimeter: " & Perimeter
Text1.Text = ""
Text1.SetFocus
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

8/6/2003 7:43:00 AMPaul

hmm Radius of a square? There is no 'radius' of a square because it would depend on what way you point it, for example if it points at top right corner, the length would be 1/2*((lenght^2)+(length^2)) (pythagoras' theorum), but if it points elsewhere the formula becomes more complex still...
(If this comment was disrespectful, please report it.)

 
8/6/2003 7:44:22 AMPaul

sorry ... that dosnt make much sense, what i mean to say is that radius can only be applied to circular shapes because the distance from the centre to the perimeter or circumference must be constant
(If this comment was disrespectful, please report it.)

 
8/6/2003 5:09:10 PMTroy Williams

Wouldn't the radius refer to the radius of the inscribed circle? At least that is what I gather from the code.
(If this comment was disrespectful, please report it.)

 
8/31/2003 9:09:46 AM

Paul your way off there son,
The proper formula is A^2+B^2=C^2 not .5 etc....stay connected
(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.