Question

The val() function seems to understand . as a decimal point, even on systems with , as a decimal point. For example, the following call

val("7,3") + 1,4

returns the real number 8,4 (8.4 in English notation). val("7.3") + 1,4 returns the expected value 8,7.

Is this a feature or a bug? How can I specify which decimal point will be used in function val()?

Was it helpful?

Solution

According to the documentation:

Note The Val function recognizes only the period (.) as a valid decimal separator. When different decimal separators are used, as in international applications, use CDbl instead to convert a string to a number.

Note: Val(7,3)+1,4 also returns 8,4, so be careful if your input already is in the number format!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top