Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need fixed number of decimal places...zero filled 2

Status
Not open for further replies.

patrussell

Technical User
May 14, 2001
71
US
I have an application that requires numbers to be displayed with a fixed number of decimal places, regardless of the number entered. For example, 5.123 would display as 5.12300. I have not been able to find anything that helps with doing this. Thanks for your help and time.

Pat Russell
 
formatnumber(5.123, 5)

the full syntax is this:
FormatNumber(Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])

gusset
 
have you tried format?

Private Sub Command1_Click()

Dim MyNum As Double

MyNum = 5.123

Label1.Caption = Format(MyNum, "#.00000")

End Sub

good luck!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
come on... get involved!
To get the best response to a question, please check out FAQ222-2244 first
A General Guide To Excel in VB FAQ222-3383
 
patrussell,

Just a question, which may not even pertain to your situation:

What should happen with a number like 5.123005 ?
Should it round up (5.12301), or not round at all?

If it is not to round at all, then use:

Text1.Text = Format$((Int(TheNumber * 10 ^ 5) / 10 ^ 5), "0.00000")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top