Vyom World.com Let's Touch the Sky Together!
 Home VyomWorld.com Home Free Magazines! VyomLinks.com Home JobsAssist.com Home Vyom Network Contact Us Jobs & Careers Resume Submitter Placement Papers IT Companies Directory Computer Jobs Interview Questions Online Exams Vyom Career eMag. Fun Screensavers New! Send FREE SMS! SMS Jokes Source Codes Library Source Codes Home ASP Source Codes C Source Codes C++ Source Codes COBOL Source Codes Java Source Codes Pascal Source Codes Submit Source Codes GATE GATE an Overview GATE Preparation Study Materal GRE GRE an Overview GRE Questions GRE Preparation GRE Universities TOEFL Preparation TOEFL Resources GMAT Preparation GMAT Resources MBA Preparation MBA Resources Networking Concepts Networking Concepts Testing Preparation Testing Resources Webmasters Free Traffic Builder Webmaster Articles Web Hosting Tutorials Hardware Tutorial 1500 Free eBooks New! FREE Publications
Vyom Career eMag.
 Get 9,000+ Interview Questions & Answers in an eBook. 9,000+ Interview Questions All Questions Answered 5 FREE Bonuses Free Upgrades Get it now!
Get 9,000+ Interview Questions with Answers in an eBook

Home >> Source Codes Library Home >> Language Home >> Category Home > > Item Description
Search Code Library

 Title CalcArea Function Description: 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. Hits: 1069 Since 25th November, 2003 Code: Select and Copy the 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 %>

ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home