18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong> <strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong><br />

Round<br />

Description Returns a number rounded to a specified number of decimal places<br />

Usage Round(expression[, numdecimalplaces])<br />

Arguments expression<br />

Required. Numeric expression being rounded.<br />

numdecimalplaces<br />

Optional. Number indicating how many places to the right of the decimal are included in the<br />

rounding. If omitted, integers are returned by the Round function.<br />

Return A Variant subtype Double. A number rounded to a specified number of decimal places.<br />

Remarks The Round function per<strong>for</strong>ms round to even, which is different from round to larger. The return<br />

value is the number closest to the value of expression, with the appropriate number of decimal<br />

places. If expression is exactly halfway between two possible rounded values, the function<br />

returns the possible rounded value whose rightmost digit is an even number. (In a round to larger<br />

function, a number that is halfway between two possible rounded values is always rounded to the<br />

larger number.)<br />

See also Int and Fix<br />

Example Rem Using the Round function to round a number to two decimal places:<br />

Dim MyVar, pi<br />

pi = 3.14159<br />

MyVar = Round(pi, 2) ' MyVar contains 3.14.<br />

Rem How rounding to even works:<br />

Dim var1, var2, var3, var4, var5<br />

var1 = Round(1.5) 'var1 contains 2<br />

var2 = Round(2.5) 'var2 contains 2<br />

var3 = Round(3.5) 'var3 contains 4<br />

var4 = Round(0.985, 2) 'var4 contains 0.98<br />

var5 = Round(0.995, 2) 'var5 contains 1.00<br />

RTrim<br />

Description Returns a copy of a string without leading spaces (LTrim), trailing spaces (RTrim), or both<br />

leading and trailing spaces (Trim).<br />

Usage strVal = RTrim(string)<br />

Arguments string<br />

Required. Any valid string expression.<br />

Remarks If string contains Null, Null is returned.<br />

See Also Left, LeftB, LTrim, Mid, MidB, Right, RightB, Trim<br />

Example The following example uses the LTrim, RTrim, and Trim functions to trim leading spaces, trailing<br />

spaces, and both leading and trailing spaces, respectively<br />

Dim MyVar<br />

MyVar = LTrim(" vbscript ") ' MyVar contains "vbscript ".<br />

MyVar = RTrim(" vbscript ") ' MyVar contains " vbscript".<br />

MyVar = Trim(" vbscript ") ' MyVar contains "vbscript".<br />

<strong>InduSoft</strong>, Ltd. 155

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!