Integer.FromString
From Xojo Documentation
Shared Method
Integer.FromString(value As String, Optional locale As Locale) As Integer
New in 2019r2
Supported for all project types and targets.
New in 2019r2
Supported for all project types and targets.
Converts a string form of a decimal number to an Integer. Specify a locale to convert thousands separator.
Notes
If no locale is specified, then Locale.Raw is used.
Exceptions
- InvalidArgumentException when value contains anything other than an integer (including when it is empty). Use Parse if you need to parse text that might contain non-numeric data or might be empty.
Sample Code
Convert a number in text to an integer:
This code converts a number using the US locale:
Var locale As New Locale("en-US")
Var value As Integer
value = Integer.FromString("1,234", locale) // value = 1234
Var value As Integer
value = Integer.FromString("1,234", locale) // value = 1234
You can also use an exception to catch invalid data: