devxlogo

Val Doesn’t Work on Formatted Numbers

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
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist