Public Function Val(ByVal Expression As Variant) As Double
Converts any input to a number (Double). Strings are converted using invariant culture (using decimal dot). All failures will be ignored and result in number 0.
SendDebug Val(Pi) 'Prints 3.141592653589793
SendDebug Val(-Pi) 'Prints -3.141592653589793
SendDebug Val("658.553") 'Prints 658.553
SendDebug Val("658,553") 'Prints 658553 => comma are removed (treated as meaningless thousands separators)
SendDebug Val("6,5,8,5,5,3") 'Prints 658553 => comma are removed (treated as meaningless thousands separators)
SendDebug Val(",6,5,8,5,5,3") 'Prints 0 => Starting comma is not accepted as thousands separator.
SendDebug Val("1,0,0.789") 'Prints 100.789
SendDebug Val("1,0,0.7,8,9") 'Prints 0 => Comma's invalid in decimal part, thus invalid number
SendDebug Val(Null) 'Prints 0
SendDebug Val(Nothing) 'Prints 0
SendDebug Val("-55") 'Prints -55
SendDebug Val("&hFF.FF") 'Prints 65535
SendDebug Val("0xA0-12") 'Prints 40978
SendDebug Val("&b0110010110") 'Prints 406
SendDebug Val("-3000e-2") 'Prints -30 (interpreted as scientific number notation)
SendDebug Val("-3000e-2.0") 'Prints 0 (invalid scientific number)