Posted to microsoft.public.excel.programming
|
|
Currency format for combo box in a user form
Thank you, it works great! Thank you also for explaining it so clearly, very
helpful.
Regards,
Jennifer
"Fadi Chalouhi" wrote:
Hi Jennifer,
(1) you need to select a format to apply to the currency : for example,
if you want the currency to be formatted as : 1,234.56, then your code
should be :
Me.txtPrice.Value = FormatCurrency(Me.txtPrice, "#,###,###.00")
(2) the code above does not apply a permanent format to the text box,
instead it just modifies the string inside the text box.
(3) move the code from the initialize procedure to the textbox Enter
and Exit procedures to get a consistent currency format:
Private Sub txtPrice_Enter()
txtPrice.Value = Format(Me.txtPrice.Value, "")
End Sub
Private Sub txtPrice_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtPrice.Value = Format(Me.txtPrice.Value, "#,###,###.00")
End Sub
this automatically modifies the format of the text box as soon as it
loses focus, and automatically formats it back to an "editable" format
when you enter the text box again.
HTH
Fadi
www.chalouhis.com/XLBLOG
|