CSng - function of language VBScript

Returns an expression that has been converted to type Single.

For the purposes of PROMOTIC system, it is more usefull to use the method: Pm.ToNumber.

CSng(expression As Variant) As Single
n = CSng(expression)
expression(Variant) Any valid expression.

The conversion functions can be used e.g. if you want some operation result to be expressed as a particular data type (rather than the default data type). For example, use CDbl or CSng to force double-precision or single-precision arithmetic in cases where integer arithmetic normally would occur.

Use the CSng function to provide internationally aware conversions from any other data type to a Single type. For example, different decimal separators and thousands separators are properly recognized depending on the locale setting of Windows system.

If expression lies outside the acceptable range for the Single type, then an error occurs.

Caution: This function can convert only values with separators set locally (e.g. value 3.14 or 3,14). Therefore a problem arises when values in the text form originate on another computer with different setting. That's why it is recommended the Pm.CSng method that solves this problem!
VBScriptSelect and copy to clipboard

Dim nDouble1, nDouble2, nSingle1, nSingle2
nDouble1 = 75.3421115
nDouble2 = 75.3421555
nSingle1 = CSng(nDouble1)  'nInt contains 75.34211
nSingle2 = CSng(nDouble2)  'nInt contains 75.34216
PROMOTIC 8.3.29 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice