Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Number Formats In A UserForm TextBox
Greetings,
I have a TextBox on a UserForm that I need to format as currency with the Exit event. I can't seem to find what the correct syntax is for this to happen. Anyone have any ideas on how this should look? TIA -Minitman |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Number Formats In A UserForm TextBox
Hi
if you want this as string value have a look at the format method. e.g. var=format(textbox1.value,"0.00 $") -- Regards Frank Kabel Frankfurt, Germany "Minitman" schrieb im Newsbeitrag ... Greetings, I have a TextBox on a UserForm that I need to format as currency with the Exit event. I can't seem to find what the correct syntax is for this to happen. Anyone have any ideas on how this should look? TIA -Minitman |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Number Formats In A UserForm TextBox
Follwoing code will format it to $1,234.56 format:
Put it in to TextBox Exit event. TextBox1.Value = Format(TextBox1.Value, """$""#,##0.00") Sharad "Minitman" wrote in message ... Greetings, I have a TextBox on a UserForm that I need to format as currency with the Exit event. I can't seem to find what the correct syntax is for this to happen. Anyone have any ideas on how this should look? TIA -Minitman |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Number Formats In A UserForm TextBox
You don't need to double-double quote the $ sign
s# = 1234.56 ? Format(s, """$""#,##0.00") $1,234.56 ? format(s,"$ #,##0.00") $ 1,234.56 I added a space in the second, but that makes no difference: (just for clarity) ? format(s,"$#,##0.00") $1,234.56 so for the OP Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Textbox1.Text = format(cdbl(Textbox1.Text),"$ #,##0.00") End Sub or (cdbl is optional - excel will coerce the string) Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Textbox1.Text = format(Textbox1.Text,"$ #,##0.00") End Sub -- Regards, Tom Ogilvy "Sharad Naik" wrote in message ... Follwoing code will format it to $1,234.56 format: Put it in to TextBox Exit event. TextBox1.Value = Format(TextBox1.Value, """$""#,##0.00") Sharad "Minitman" wrote in message ... Greetings, I have a TextBox on a UserForm that I need to format as currency with the Exit event. I can't seem to find what the correct syntax is for this to happen. Anyone have any ideas on how this should look? TIA -Minitman |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Number Formats In A UserForm TextBox
Yes, for standard currency symbol no need to double-dobule quote. For
currency symbol not appearing in the cell number format in excel, double quote is needed. Sharad "Tom Ogilvy" wrote in message ... You don't need to double-double quote the $ sign s# = 1234.56 ? Format(s, """$""#,##0.00") $1,234.56 ? format(s,"$ #,##0.00") $ 1,234.56 I added a space in the second, but that makes no difference: (just for clarity) ? format(s,"$#,##0.00") $1,234.56 so for the OP Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Textbox1.Text = format(cdbl(Textbox1.Text),"$ #,##0.00") End Sub or (cdbl is optional - excel will coerce the string) Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Textbox1.Text = format(Textbox1.Text,"$ #,##0.00") End Sub -- Regards, Tom Ogilvy "Sharad Naik" wrote in message ... Follwoing code will format it to $1,234.56 format: Put it in to TextBox Exit event. TextBox1.Value = Format(TextBox1.Value, """$""#,##0.00") Sharad "Minitman" wrote in message ... Greetings, I have a TextBox on a UserForm that I need to format as currency with the Exit event. I can't seem to find what the correct syntax is for this to happen. Anyone have any ideas on how this should look? TIA -Minitman |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Number Formats In A UserForm TextBox
Not exactly true either. As long as the characters used are not formatting
characters, there is no need: ? format(1234.56,"AB#,##0.00") AB1,234.56 AB certainly isn't a standard currency symbol. ABC causes problems: ? format(1234.56,"ABC#,##0.00") AB5/18/1903 1:26:24 PM#,##0.00 but you can fix that with ? format(1234.56,"AB\C#,##0.00") ABC1,234.56 -- Regards, Tom Ogilvy "Sharad Naik" wrote in message ... Yes, for standard currency symbol no need to double-dobule quote. For currency symbol not appearing in the cell number format in excel, double quote is needed. Sharad "Tom Ogilvy" wrote in message ... You don't need to double-double quote the $ sign s# = 1234.56 ? Format(s, """$""#,##0.00") $1,234.56 ? format(s,"$ #,##0.00") $ 1,234.56 I added a space in the second, but that makes no difference: (just for clarity) ? format(s,"$#,##0.00") $1,234.56 so for the OP Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Textbox1.Text = format(cdbl(Textbox1.Text),"$ #,##0.00") End Sub or (cdbl is optional - excel will coerce the string) Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Textbox1.Text = format(Textbox1.Text,"$ #,##0.00") End Sub -- Regards, Tom Ogilvy "Sharad Naik" wrote in message ... Follwoing code will format it to $1,234.56 format: Put it in to TextBox Exit event. TextBox1.Value = Format(TextBox1.Value, """$""#,##0.00") Sharad "Minitman" wrote in message ... Greetings, I have a TextBox on a UserForm that I need to format as currency with the Exit event. I can't seem to find what the correct syntax is for this to happen. Anyone have any ideas on how this should look? TIA -Minitman |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Number Formats In A UserForm TextBox
Hey Tom,
Thanks for the answer and the lesson. It always helps to understand how the answer works. -Minitman On Sat, 23 Oct 2004 10:20:07 -0400, "Tom Ogilvy" wrote: You don't need to double-double quote the $ sign s# = 1234.56 ? Format(s, """$""#,##0.00") $1,234.56 ? format(s,"$ #,##0.00") $ 1,234.56 I added a space in the second, but that makes no difference: (just for clarity) ? format(s,"$#,##0.00") $1,234.56 so for the OP Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Textbox1.Text = format(cdbl(Textbox1.Text),"$ #,##0.00") End Sub or (cdbl is optional - excel will coerce the string) Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Textbox1.Text = format(Textbox1.Text,"$ #,##0.00") End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Userform textbox number formats | Excel Discussion (Misc queries) | |||
userform textbox | Excel Worksheet Functions | |||
Textbox in userform | Excel Programming | |||
Formatting number in a UserForm TextBox | Excel Programming | |||
UserForm TextBox to ActiveSheet TextBox over 256 characters | Excel Programming |