How to use only two digits after . in decimal

Hi,
I have input string value like “12.000” its in decimal i need only 2 digits after (.) like this 12.00 or 12 how can we do this i get error when i use the format
image

Can anyone help me?

Thanks
Chethan P

Hi @copy_writes

taxval should be Generic datatype, can you change and retry again

1 Like

convert “taxval” to int , Like below

newintVariable = cint(taxval)

1 Like

genaric is working but i am resiving the value is string i dont want to convert to string

AND if the value is 12.546 i need only 12.54

You can try this

Convert.ToDecimal("21.000").ToString("N")

or

CDbl("21.000").ToString("N")

Hi @copy_writes

Try like this

Math.Round(CDBl(taxval),2).ToString

Or

Math.Round(Convert.ToDecimal("12.000"),2).ToString

Just adding one more way as well

3 Likes

what is CDB1

CDBl -----------------> Convert to double

1 Like

If it’s type double then you can use this syntax:
cdbl(Math.Round(existingvalue,2))

1 Like

Thank you bro again you saved me and thanks to every one

Hi @copy_writes

If your issue is resolved, kindly mark the appropriate answer as solution so that we can close the topic :blush:

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