954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

VB SCRIPT Rounding

Using VbScript::

I have a list of several different prices and I'm trying to figure out how to round these 5 decimals adding zeros if necessary.

For example:

I want
2.84
3.1
4.896

to look like
2.84000
3.10000
4.89600

Can somebody please help me? Thanks!

jcb0806
Newbie Poster
14 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 
Dim num1 As Double = 2.8399999999999999
		Dim num2 As Double = 3.1000000000000001
		Dim num3 As Double = 4.8689999999999998

		Debug.WriteLine(num1.ToString("F5"))
		Debug.WriteLine(num2.ToString("F5"))
		Debug.WriteLine(num3.ToString("F5"))


Retruns:
2,84000
3,10000
4,86900

GeekByChoiCe
Master Poster
721 posts since Jun 2009
Reputation Points: 208
Solved Threads: 168
 
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 

Thanks to all the responses. I used

formatnumber(2.84, 5)

made it look like 2.84000

Again appreciate all the help!

jcb0806
Newbie Poster
14 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: