From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../source/text/sbasic/shared/03170000.xhp | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 helpcontent2/source/text/sbasic/shared/03170000.xhp (limited to 'helpcontent2/source/text/sbasic/shared/03170000.xhp') diff --git a/helpcontent2/source/text/sbasic/shared/03170000.xhp b/helpcontent2/source/text/sbasic/shared/03170000.xhp new file mode 100644 index 000000000..7f5d824fb --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03170000.xhp @@ -0,0 +1,84 @@ + + + + + + + Round Function [VBA] + /text/sbasic/shared/03170000.xhp + + + + +
+ + Round function (VBA) + +

Round Function [VBA]

+ Rounds a numeric value to a specified number of decimal digits. +
+ + This function implements the rounding rule known as "round-to-even". With this rule, whenever the difference between the number to be rounded and its nearest integer is equal to 0.5, the number is rounded to the nearest even number. See the examples below to learn more about this rule. + Beware that VBA's Round function works differently than %PRODUCTNAME Calc's Round function. In Calc, if the difference between the number to be rounded and the nearest integer is exactly 0.5, then the number is rounded up. Hence, in Calc the number 2.5 is rounded to 3 whereas using VBA's Round function the value 2.5 is rounded to 2 due to the "round-to-even" rule. + + + Round(expression [,numdecimalplaces]) + + + Double + + expression: The numeric expression to be rounded. + numdecimalplaces: Optional argument that specifies the number of decimal digits in the resulting rounded value. The default value is 0. + + + + + Option VBASupport 1 + Sub Example_Round + Dim r + r = Pi + print r ' 3,14159265358979 + print Round(r, 5) ' 3,14159 + r = exp(1) + print r ' 2,71828182845904 + print Round(r) ' 3 + End Sub + +
+ The following examples illustrate the "round-to-even" rule: +
+ + ' Rounding to the nearest integer (decimalplaces = 0) + MsgBox Round(3.5) ' 4 + MsgBox Round(4.5) ' 4 + MsgBox Round(5.5) ' 6 + MsgBox Round(6.5) ' 6 + ' Rounding with 2 decimal digits (decimalplaces = 2) + MsgBox Round(1.555, 2) ' 1.56 + MsgBox Round(1.565, 2) ' 1.56 + MsgBox Round(1.575, 2) ' 1.58 + MsgBox Round(1.585, 2) ' 1.58 + + +
+ Calc ROUND function + +
+ +
-- cgit v1.2.3