I'm trying to format a number to 3 decimal places (eg. 123.45678 to 123.457, but it is returning 123.5). Anyone has an idea?
Format$(CDbl(Value), "####.000")
Printable View
I'm trying to format a number to 3 decimal places (eg. 123.45678 to 123.457, but it is returning 123.5). Anyone has an idea?
Format$(CDbl(Value), "####.000")
Use FormatNumber("123.45678", 3)
Still returning 1 decimal place.
FormatNumber(CDbl(Value), 3, , , vbTrue)
I'm not sure what you are doing wrong, but this works.
MsgBox FormatNumber(CDbl(312.123456), 3)
It returns 312.123
What is the number you are formatting?
My number is 14.3 as a String, then I use CDbl to convert it to double. I want this number to display as 14.30
Then display it that way - but you cannot store it that way in a Double, only in a String.
I have a list of numbers, showing in 1, 2 and 3 decimal places. I want display them all in 3 decimal places. I've tried just use FormatNumber(Value), 3, , , vbTrue) and FormatNumber(CStr(Value), 3, , , vbTrue), both of them returned the original decimal places.
Show us the actual code you are using (not just part of a line, but the relevant section of code and variable declarations).
Note that all 1001 of these numbers display in a list box exactly three places to the right of the decimal:
Code:For I = 0 To 1000
List1.AddItem Format$(Sqr(9 + I), "###.000")
Next
vb Code:
Private Sub Command1_Click() Dim parse() As String Dim X As String If InStr(Text1.Text, ".") Then parse = Split(Text1.Text, ".") X = Left(parse(1), 3) Text1.Text = parse(0) & "." & X End If End Sub