## CalcArea

Calculates the area of objects.
Pass formula argument as string and values as an array.
CalcArea returns a double.
Needs Pi() as function
The following chart displays the acceptable values of the formula and values argument:
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

Function CalcArea(byVal formula, byVal values)
' Const Pi = 3.1415926535897932
PiVal      = Pi()
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 = PiVal * r ^ 2
Case "ellipse"
r1 = CDbl( values(0) )
r2 = CDbl( values(1) )
mth = PiVal * r1 * r2
End Select
mth = CDbl( mth )
CalcArea = mth
End Function
formula, values