Signature (Visual Basic / VBA)
Public Function RectangleCalc( _
Optional ByVal vArea As Variant _
, Optional ByVal vDiagonal As Variant _
, Optional ByVal vLength As Variant _
, Optional ByVal vPerimeter As Variant _
, Optional ByVal vWidth As Variant _
) As Variant
Code Example
RectangleCalc(vArea:=20, vDiagonal:=8, vLength:="CALC") = 2.6495297708096
RectangleCalc(vArea:=20, vDiagonal:=8, vWidth:="CALC") = 7.54850925637597
RectangleCalc(vLength:=10, vWidth:=12, vPerimeter:="CALC") = 44
RectangleCalc(vLength:=12, vWidth:=10, vPerimeter:="CALC") = 44
RectangleCalc(Null, Null, 12, "CALC", 10) = 44
Parameters
| Parameter | Description |
|---|---|
| vArea | Area of the rectangle. |
| vDiagonal | Length of the diagonal line between any two opposing corners. |
| vLength | Length of the shorter of the two sides of the rectangle. |
| vPerimeter | Perimeter around the rectangle. |
| vWidth | Length of the longer of the two sides of the rectangle. |
Notes & Version History
| Summary | Two of the arguments should contain a numeric value--the given values for those properties. Pass the word "CALC" to the argument whose value is to be calculated and returned by this function. The other arguments should be missing or Null or non-numeric. Function returns Null if it could not calculate the requested property from the values provided. Otherwise, the function returns the value of the property whose argument was passed the word "CALC". |
| Note | When the length is to be calculated and the width is unknown, the length is considered to be the shorter of the two sides. When both the length and width are known values supplied to this function, either one can be smaller than the other. |
| Note | When the width is to be calculated and the length is unknown, the width is considered to be the longer of the two sides. When both the width and length are known values supplied to this function, either one can be smaller than the other. |
| Note | Function may return a complex number in the form of a string if the given dimensions are not consistent with the shape. |
| Note | The match on the word "CALC" is case-insensitive, so for example, "CALC" and "Calc" match each other. |