[RESOLVED] Format user input as currency
When a user enters data in a spread sheet the spread sheet can be formatted so that (say) 36 appears as $36.00, or 25/3/9 appears as 25-Mar-09.
What I want to do is the same sort of thing in a User Form, so that when the user has entered a number and tabs to the next field the number looks like currency.
I have several label captions that take the user input and remove the tax to provide a nett value, or that add bank fees which I have been able to format. (This form sits in an excel file.)
Re: Format user input as currency
try the FormatCurrency Vb function:
Code:
TextBox1.Text = ".1"
MsgBox FormatCurrency(TextBox1.Text) 'Should be $0.10
TextBox1.Text = "5"
MsgBox FormatCurrency(TextBox1.Text) 'Should be $5.00
TextBox1.Text = "10000000"
MsgBox FormatCurrency(TextBox1.Text) 'Should be $10,000,000.00
There's different optional parameters you can pass, listed on the MS site I linked above.
Re: Format user input as currency
be careful of using the formatted strings, in the textboxes, if you want to do any calculations using the values
vb Code:
text1 = "25/3/9"
text1 = format(text1, "dd-mmm-yy")
Re: Format user input as currency
I've been thinking about this one some more: I don't think that what I want to do is possible in Excel. (I was thinking in terms of a number of mainframe applications I've met where the user input is not formatted until it is used somewhere later in the program.) The type of formatting I want can be done in Access, with an input mask. So I'll mark this one as resolved - just as soon as I find out how to do that!
Re: [RESOLVED] Format user input as currency
Quote:
was thinking in terms of a number of mainframe applications I've met where the user input is not formatted until it is used somewhere later in the program.
of course you can do like that