IntVal

Public Function IntVal(ByVal Expression As Variant) As Long

Converts any input to a number (32 bit Long). Strings are converted using invariant culture (using decimal dot). All failures will be ignored and result in number 0.

SendDebug IntVal(Pi) 'Prints 3
SendDebug IntVal(-Pi) 'Prints -3
SendDebug IntVal("658.553") 'Prints 658
SendDebug IntVal("658,553") 'Prints 658553  => comma are removed (treated as meaningless thousands separators)
SendDebug IntVal("6,5,8,5,5,3") 'Prints 658553  => comma are removed (treated as meaningless thousands separators)
SendDebug IntVal(",6,5,8,5,5,3") 'Prints 0  => Starting comma is not accepted as thousands separator.
SendDebug IntVal("1,0,0.789") 'Prints 100
SendDebug IntVal("1,0,0.7,8,9") 'Prints 0  => Comma's invalid in decimal part, thus invalid number
SendDebug IntVal(Null) 'Prints 0
SendDebug IntVal(Nothing) 'Prints 0
SendDebug IntVal("-55") 'Prints -55
SendDebug IntVal("&hFFFF") 'Prints 65535
SendDebug IntVal("0xA012") 'Prints 40978
SendDebug IntVal("&b0110010110") 'Prints 406
SendDebug IntVal("-3000e-2") 'Prints -30 (-3000 * 10^-2 = -3000 * 0.01 = -30)
SendDebug IntVal("-3000e-2.0") 'Prints 0 (invalid scientific number)

See also: