How to write a number with 2 and 3 decimals?

Hi,
I get a number from an excel and assign it in a variable. My variable has 2 decimals. I need to write this variable with 2 decimals in some places of a web page but sometimes I need to write with 3 decimals.
How can I do that?
Thanks.

@makboga

You can use Format value activity.

Thanks

image

HI @makboga

Checkout this expression

For two decimals

CDec("2435.1256").ToString("#.00")

image

For three decimals

CDec("2435.1256").ToString("#.000")

image

Regards
Sudharsan

I get the error that says "Option Strict On disallows implicit conversions from ‘String’ to ‘Double’. "
How can I fix this?

Have you tried this? @makboga

And can you show a screenshot?

Regards
Sudharsan

Yes I tried and I get this error.
image

Hi @makboga ,

Could you show us the Input value and How it needs to be typed into the webpage when done manually?

Your value is a string, so you can’t use the .ToString(“F3”) on it. That only works on variables with datatype Double. So you need to convert to Double first:

CDbl(yourStringVal).ToString(“F3”)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.