Val Doesn’t Work on Formatted Numbers

Beware of the Val() function. It doesn’t correctly recognize formatted numbers. Use CInt(), CDbl(), and soon instead:

 FormattedString = Format(1250, _        "General")            ' = "1,250.00"Debug.Print Val(FormattedString)        ' prints 1 !Debug.Print cDbl(FormattedString)        ' prints 1250
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: