|
-
Jun 4th, 2009, 08:48 AM
#1
Thread Starter
Addicted Member
[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.)
-
Jun 4th, 2009, 09:10 AM
#2
Lively Member
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.
Last edited by nanoinfinity; Jun 4th, 2009 at 09:14 AM.
Reason: added better example
-
Jun 4th, 2009, 04:42 PM
#3
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")
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 12th, 2009, 07:07 PM
#4
Thread Starter
Addicted Member
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!
-
Jun 12th, 2009, 10:24 PM
#5
Re: [RESOLVED] Format user input as currency
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|