ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / String functions
  • Conversion range
  • Val function and UNICODE
  • Miscellaneous
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
<ANSI string type>.ToNum (Function)
In french: <Type Chaîne ansi>.VersNumérique
Returns the numeric value of a character string. This feature enables you to perform numeric calculations on strings.
Remark: This function is equivalent to Val.
Example
s is string
s = "143"
s.ToNum()    // Returns 143
s = "1.67"
s.ToNum()   // Returns 1.67
s = "ABC"
s.ToNum()    // Returns 0
s = "3plus2"
s.ToNum() // Returns 3
s = "7,5"
s.ToNum()    // Returns 7
s = "1D2"
s.ToNum()    // Returns 100
s = "2.5e-2"
s.ToNum() // Returns 0.025
Syntax
<Result> = <Initial string>.ToNum([<Base used>])
<Result>: Real or integer
  • Numeric value of the string.
  • "inf" (for " Infinite "), if the result exceeds the capabilities of a real. We advise you to use the conversion to an Variable of type Integer.
  • 0 if an error occurs.
AndroidAndroid Widget Java In this version, <Result> corresponds to a real.
<Initial string>: Character string or Buffer
Character string to convert to a numeric value.
For a real, the separator must be the dot ('.') and the prefixes for scientific notation can be 'E', 'e', 'D' or 'd'. If the separator is a comma, the numbers after the comma will be ignored.
This parameter can also be a buffer. In this case, the buffer will be processed differently, according to the option selected in the "Unicode" tab of the configuration description:
  • if "Use ANSI strings at runtime" is selected, the buffer will be processed as an ANSI string.
  • if "Use UNICODE strings at runtime" is selected, the buffer will be processed as an ANSI or UNICODE string, depending on its content.
<Base used>: Character string or integer (optional)
Base in which the number is represented. The possible values are as follows:
  • "d": base 10 (decimal),
  • "x": base 16 (hexadecimal),
  • "o": base 8 (octal),
  • an integer between 2 and 36.
Base 10 is used by default.
WEBDEV - Browser codeUniversal Windows 10 App This parameter is not available. Base 10 is automatically used.
Remarks

Conversion range

<ANSI string type>.ToNum converts a string to an integer if the value is between -9.223.372.036.854.775.808 and 9.223.372.036.854.775.807.

Val function and UNICODE

The <Initial string> can be an ANSI or UNICODE string
For more details on UNICODE, see Managing UNICODE.

Miscellaneous

If a character of <Initial string> cannot be interpreted as a number, <ANSI string type>.ToNum stops interpreting <Initial string> and returns the number corresponding to the characters already read.
Reals can be converted from base 10 only. In other bases, all characters after "." (point) will be ignored.
Component: wd290vm.dll
Minimum version required
  • Version 27
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/19/2023

Send a report | Local help