CalcArea Function:

The CalcArea function calculates the area of objects. There are two required arguments: formula and values. The formula argument must be a string and the values argument must be an array. The following chart displays the acceptable values of the formula and values argument:
formula argument (string) values argument (array)
triangle array(0) = base
array(1) = height
square array(0) = side
rectangle array(0) = side1
array(1) = side2
parallelogram array(0) = base
array(1) = height
trapezoid array(0) = base1
array(1) = base2
array(2) = height
circle array(0) = radius
ellipse array(0) = radius1
array(1) = radius2

CalcArea always returns a double.

Syntax:
double = CalcArea(formula, values)
Example Usage:
<% = CalcArea( "triangle", Array( 100.3, 51.2 ) )  %><BR>
Area of a triangle: base=100.3 height=51.2
CalcArea returns 2567.68

<% = CalcArea( "square", Array( 21 ) )  %><BR>
Area of a square: side=21
CalcArea returns 441

<% = CalcArea( "rectangle", Array( 12.32, 65.06 ) )  %><BR>
Area of a rectangle: side1=12.32 side2=65.06
CalcArea returns 801.5392

<% = CalcArea( "parallelogram", Array( 12.32, 5.56 ) ) %><BR>
Area of a parallelogram: base=12.32 height=5.56
CalcArea returns 68.4992

<% = CalcArea( "trapezoid", Array( 45.60778, 564.9849, 6.35484 ) )  %><BR>
Area of a trapezoid: base1=45.60778 base2=564.9849 height=6.35484
CalcArea returns 1940.1093932856

<% = CalcArea( "circle", Array( 12.456 ) )  %><BR>
Area of a circle: radius=12.456
CalcArea returns 487.424182327834

<% = CalcArea( "ellipse", Array( 45.01, 6.7524 ) )  %><BR>
Area of a ellipse: radius1=45.01 radius2=6.7524
CalcArea returns 954.810193436828

ASP Source Code:
<%
Private Function CalcArea(byVal formula, byVal values)
	Const Pi = 3.1415926535897932
	Dim mth, b, b1, b2, h, r, r1, r2, s, s1, s2
	Select Case LCase( formula )
		Case "triangle"
			b = CDbl( values(0) )
			h = CDbl( values(1) )
			mth = b * h * 0.5
		Case "square"
			s = CDbl( values(0) )
			mth = s ^ 2
		Case "rectangle"
			s1 = CDbl( values(0) )
			s2 = CDbl( values(1) )
			mth = s1 * s2
		Case "parallelogram"
			b = CDbl( values(0) )
			h = CDbl( values(1) )
			mth = b * h
		Case "trapezoid"
			b1 = CDbl( values(0) )
			b2 = CDbl( values(1) )
			h  = CDbl( values(2) )
			mth = h / 2 * (b1 + b2)
		Case "circle"
			r = CDbl( values(0) )
			mth = pi * r ^ 2
		Case "ellipse"
			r1 = CDbl( values(0) )
			r2 = CDbl( values(1) )
			mth = pi * r1 * r2
	End Select
	mth = CDbl( mth )
	CalcArea = mth
End Function
%>