From Xojo Documentation


Returns the numeric form of a string as an Int64.



Part Type Description
result Int64 The numeric equivalent of the source String.
stringVariable String Any variable of type String.


The ToInt64 function stops reading the string at the first character it doesn’t recognize as part of a number. All other characters are automatically stripped.

It does recognize prefixes &o (octal), &b (binary), and &h (hexadecimal). However, spaces are not allowed in front of the ampersand. That is, " &hFF" returns 0, but "&hFF" returns 255.

ToInt64 returns zero if string contains no numbers.

Sample Code

This code use the ToInt64 function to return the numbers contained in a string literal or a string variable

Var result As Int64
Var source As String = "12345"
result = source.ToInt64 // returns 12345

source = " 12345"
result = source.ToInt64 // returns 0

source = "123 45"
result = source.ToInt64 // returns 123

source = "&hFFF"
result = source.ToInt64 // returns 4095

source = "&b1111"
result = source.ToInt64 // returns 15

See Also

String.ToDouble, CStr, Int64.FromString, Str, Val functions; &b, &h, &o literals; Int64 data type