Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 212
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 212
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform textbox number formats PhilM Excel Discussion (Misc queries) 2 June 7th 06 11:08 AM
userform textbox Phil Excel Worksheet Functions 5 January 16th 05 06:59 PM
Textbox in userform shaharul[_6_] Excel Programming 3 April 15th 04 12:54 PM
Formatting number in a UserForm TextBox John Pierce Excel Programming 3 January 26th 04 04:57 PM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 06:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"