Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

vb.net Math.Round drops last 0 in price?

I am using a Math.Round function in my program as follows

Math.Round((ProductWeightByType * 4.18), 2)

This works perfect except for when the last character is already a 0 then it drops that 0 so example $1.70 becomes $1.7

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How do i fix this?

>Solution :

you should try using string format, something like this could do what you need:

String.Format("{0:C2}", Math.Round((ProductWeightByType * 4.18), 2))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading