You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your code uses the CDec function, which causes an error when the system sets the Comma character as the decimal separator. In this case, you must replace the period with a comma before using the function. The Val function doesn't require this because it uses a period as the decimal separator. However, the Val function only supports a limited number of 14 decimal digits.
@SanbiVN This repo already handles the decimal separator regardless of the regional settings. Can you provide an example of a combination of setting and code that can trigger the error? Thanks!
I've read the source code, and I don't understand how your code handles it. But it's clever; you used CStr to get the decimal separator without needing any complicated code.
chDot = AscW(Mid$(CStr(1.1), 2, 1))
The code I usually use to handle the decimal separator is:
IIF("1.1" = 1.1,".",",")
Thank you. LibJson is quite powerful for parsing JSON.
Just a note, because you mentioned the Val method. Unfortunately Val would lose precision for Decimal and would only retain precision for Double values. As a bonus, the adopted method is also faster than using Val.
Activity
[-]Convert decimal numbers in VBA Office 365 Windows 11[/-][+]Convert decimal numbers[/+]cristianbuse commentedon Apr 27, 2026
@SanbiVN This repo already handles the decimal separator regardless of the regional settings. Can you provide an example of a combination of setting and code that can trigger the error? Thanks!
SanbiVN commentedon Apr 27, 2026
I've read the source code, and I don't understand how your code handles it. But it's clever; you used CStr to get the decimal separator without needing any complicated code.
chDot = AscW(Mid$(CStr(1.1), 2, 1))The code I usually use to handle the decimal separator is:
IIF("1.1" = 1.1,".",",")Thank you. LibJson is quite powerful for parsing JSON.
cristianbuse commentedon Apr 27, 2026
Thank you for the kind words!
Just a note, because you mentioned the
Valmethod. UnfortunatelyValwould lose precision for Decimal and would only retain precision forDoublevalues. As a bonus, the adopted method is also faster than usingVal.