ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Format of a TextBox in a userform (https://www.excelbanter.com/excel-programming/320720-format-textbox-userform.html)

MD

Format of a TextBox in a userform
 
Good day,

I have a userform that has a TextBox. In this TextBox, I want to enter
dollar amounts so that it looks like this: 1 234 567 $. Right now I get
this: 1234567.

regards,

MD



Sharad Naik

Format of a TextBox in a userform
 
In the TextBox_Change event add following code

TextBox1.Text = Replace(Format(TextBox1.Text, "#,##0 \$"), ",", " ")\

Sharad

"MD" wrote in message
...
Good day,

I have a userform that has a TextBox. In this TextBox, I want to enter
dollar amounts so that it looks like this: 1 234 567 $. Right now I get
this: 1234567.

regards,

MD




Bob Phillips[_6_]

Format of a TextBox in a userform
 
Try,

Textbox1.Text = Format(the_amount,"# ### ##0$")

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MD" wrote in message
...
Good day,

I have a userform that has a TextBox. In this TextBox, I want to enter
dollar amounts so that it looks like this: 1 234 567 $. Right now I get
this: 1234567.

regards,

MD





MD

Format of a TextBox in a userform
 
Thx Bob, onw more Q. I actually have 3 textboxes, when I run the code it
only does it on 1... I have the code setup like so...

Private Sub UserForm_Initialize()
volet_1.TextBox11.Value = Format(Sheets("data").Range("a11").Value, "#
### ##0 $")
volet_1.TextBox12.Value = Format(Sheets("data").Range("A12").Value, "#
### ##0 $")
volet_1.TextBox13.Value = Format(Sheets("data").Range("a13").Value, "#
### ##0 $")

End Sub


"Bob Phillips" a écrit dans le message
de news: ...
Try,

Textbox1.Text = Format(the_amount,"# ### ##0$")

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MD" wrote in message
...
Good day,

I have a userform that has a TextBox. In this TextBox, I want to enter
dollar amounts so that it looks like this: 1 234 567 $. Right now I get
this: 1234567.

regards,

MD







Bob Phillips[_6_]

Format of a TextBox in a userform
 
I am surprised. I just created a form and tried it, and it worked fine. I
assume the form is named volet_1, and that the wrap-around we see in the NG
is not in your code.

BTW, could I suggest that you use Sharad's solution, it is better than mine
(:-)).

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MD" wrote in message
...
Thx Bob, onw more Q. I actually have 3 textboxes, when I run the code it
only does it on 1... I have the code setup like so...

Private Sub UserForm_Initialize()
volet_1.TextBox11.Value = Format(Sheets("data").Range("a11").Value, "#
### ##0 $")
volet_1.TextBox12.Value = Format(Sheets("data").Range("A12").Value, "#
### ##0 $")
volet_1.TextBox13.Value = Format(Sheets("data").Range("a13").Value, "#
### ##0 $")

End Sub


"Bob Phillips" a écrit dans le message
de news: ...
Try,

Textbox1.Text = Format(the_amount,"# ### ##0$")

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MD" wrote in message
...
Good day,

I have a userform that has a TextBox. In this TextBox, I want to enter
dollar amounts so that it looks like this: 1 234 567 $. Right now I

get
this: 1234567.

regards,

MD










All times are GMT +1. The time now is 08:14 AM.

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