ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform Textbox Currency Format Problems (https://www.excelbanter.com/excel-programming/280621-userform-textbox-currency-format-problems.html)

Dunce in SC

Userform Textbox Currency Format Problems
 
I am having trouble getting a textbox to format user input in currency
When I use the following code

Private Sub TextBoxgencost_Change()
TextBoxgencost.Text = Format(TextBoxgencost.Text, "Currency")
End Sub

Or
Private Sub TextBoxgencost_Change()
TextBoxgencost.Text = Format(TextBoxgencost.Text, "$###,###,##")
End Sub

It will only allow me to enter 4 numbers and then behaves as a counter
and increases the last digit by one .

Thanks for the help



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


Tom Ogilvy

Userform Textbox Currency Format Problems
 
Change fires every time you enter a character, so when you start getting the
results of the format, things don't work right

Private Sub TextBoxgencost_Change()
Dim sStr as String
sStr = trim(TextBoxgencost.Text)
sStr = Application.Substitute(Application. _
Substitute(sStr,",",""),"$","")
if Isnumeric(sStr) then
TextBoxgencost.Text = Format( _
TextBoxgencost.Text, "$###,###,##")
End if
End Sub

--
Regards,
Tom Ogilvy


Dunce in SC wrote in message
...
I am having trouble getting a textbox to format user input in currency
When I use the following code

Private Sub TextBoxgencost_Change()
TextBoxgencost.Text = Format(TextBoxgencost.Text, "Currency")
End Sub

Or
Private Sub TextBoxgencost_Change()
TextBoxgencost.Text = Format(TextBoxgencost.Text, "$###,###,##")
End Sub

It will only allow me to enter 4 numbers and then behaves as a counter
and increases the last digit by one .

Thanks for the help



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/




Dunce in SC[_5_]

Userform Textbox Currency Format Problems
 
Tom ..thanks for the help. That fixed it.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



All times are GMT +1. The time now is 02:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com