View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Formatting number in a UserForm TextBox

Private Sub spnInterestRate_SpinUp()
txtInterestRate.Value = format(cdbl(txtInterestRate.Value) _
+ 0.125,"0.000")
End Sub
-------------------------------------
Private Sub spnInterestRate_SpinDown()
txtInterestRate.Value = format(cdbl(txtInterestRate.Value) _
- 0.125,"0.000")
End Sub

--
Regards,
Tom Ogilvy

John Pierce wrote in message
om...
The code below is doing what I want in incrementing an
interest rate in a text box by an 1/8 of a point. I would
like it to always display to 3 decimal places, but it goes:
5.125, 5.25, 5.375, 5.5, dropping trailing zeros.
I know it needs a Format. Any help is appreciated.

Private Sub UserForm_Activate()
txtInterestRate.Value = "5.000"
etc.
------------------------------------
Private Sub spnInterestRate_SpinUp()
txtInterestRate.Value = txtInterestRate.Value + 0.125
End Sub
-------------------------------------
Private Sub spnInterestRate_SpinDown()
txtInterestRate.Value = txtInterestRate.Value - 0.125
End Sub