|
Formatting Text
|
|
10-17-2009, 12:19 PM
Post: #1
|
|||
|
|||
|
Formatting Text
I want the currency in my script to be formatted as such
$123.45 -$123.45 or ($123.45) I accomplished one line to work The problem is the rest of the code seems to not work. My question is: Can I format the whole script so currency is in the above examples? This will work but I have a problem with this code reading the () and - if the number is negative. VBS Programming
So basically, if I can format the whole script then how do I get the above code to read the text file properly if it has a negative number? undefined |
|||
|
10-17-2009, 05:30 PM
Post: #2
|
|||
|
|||
|
RE: Formatting Text
FormatCurrency returns a string. You cannot perform arithmetic functions on a string that contains characters which can't be interpreted as numbers (e.g. parenthesis).
You should only use the FormatCurrency function when you are displaying a number or writing it to an output file. Scripting problems? Windows questions? Ask the Windows Guru! Stay up to date with all of my latest content. Follow me on Twitter! Help us help you! Post your exact error message with these easy tips! |
|||
|
10-17-2009, 09:23 PM
Post: #3
|
|||
|
|||
|
RE: Formatting Text
I understand. Is there a way to to set the standard decimal position?
i.e. 123.40 instead of 123.4 undefined |
|||
|
10-17-2009, 11:25 PM
Post: #4
|
|||
|
|||
|
RE: Formatting Text
Use the second parameter of the FormatCurrency function.
Scripting problems? Windows questions? Ask the Windows Guru! Stay up to date with all of my latest content. Follow me on Twitter! Help us help you! Post your exact error message with these easy tips! |
|||
|
10-18-2009, 04:19 AM
Post: #5
|
|||
|
|||
RE: Formatting Text
(10-17-2009 11:25 PM)Nilpo Wrote: Use the second parameter of the FormatCurrency function. But, you just said I can't use the FormatCurrency function. undefined |
|||
|
10-18-2009, 02:41 PM
Post: #6
|
|||
|
|||
RE: Formatting Text
(10-18-2009 04:19 AM)hondabones Wrote:(10-17-2009 11:25 PM)Nilpo Wrote: Use the second parameter of the FormatCurrency function. I said that you should only use it when you're outputting your values. Internally, the number of decimal places is irrelevant anyway since 10.4 and 10.40 have the same numeric value. If you're concerned with the internal handling, look at the round function which will allow you to round values to a specific decimal place. This is useful when performing divisions since a currency value should be rounded to the nearest penny after each operation rather than once at the end. Scripting problems? Windows questions? Ask the Windows Guru! Stay up to date with all of my latest content. Follow me on Twitter! Help us help you! Post your exact error message with these easy tips! |
|||
|
10-18-2009, 05:21 PM
Post: #7
|
|||
|
|||
|
RE: Formatting Text
The script writes the total to a text file. That total is the then recalled back when the script is ran again. Therefore FormatCurrency is not working because as you said it returns a string which can not be used for arithmetic. I would like the script internally and externally (i.e. the log file) to maintain a standard 123.45 format.
undefined |
|||
|
10-18-2009, 08:18 PM
Post: #8
|
|||
|
|||
|
RE: Formatting Text
Internally makes no difference. Externally, use FormatCurrency as I stated earlier.
Scripting problems? Windows questions? Ask the Windows Guru! Stay up to date with all of my latest content. Follow me on Twitter! Help us help you! Post your exact error message with these easy tips! |
|||
|
10-20-2009, 03:35 AM
Post: #9
|
|||
|
|||
RE: Formatting Text
(10-18-2009 08:18 PM)Nilpo Wrote: Internally makes no difference. Externally, use FormatCurrency as I stated earlier. I can't. Like you said: (10-17-2009 05:30 PM)Nilpo Wrote: FormatCurrency returns a string. You cannot perform arithmetic functions on a string that contains characters which can't be interpreted as numbers (e.g. parenthesis). undefined |
|||
|
10-20-2009, 03:40 AM
Post: #10
|
|||
|
|||
RE: Formatting Text
(10-20-2009 03:35 AM)hondabones Wrote:(10-18-2009 08:18 PM)Nilpo Wrote: Internally makes no difference. Externally, use FormatCurrency as I stated earlier. Yes you can. I said... (10-17-2009 05:30 PM)Nilpo Wrote: You should only use the FormatCurrency function when you are displaying a number or writing it to an output file. Which is exactly what you are trying to do. Scripting problems? Windows questions? Ask the Windows Guru! Stay up to date with all of my latest content. Follow me on Twitter! Help us help you! Post your exact error message with these easy tips! |
|||
|
« Next Oldest | Next Newest »
|
| Forum Permissions |
| You cannot post new threads. You cannot post replies. You cannot post attachments. |
| HTML is turned off. MyCode is turned on. Smilies are turned on. [img] is turned on. |


Search
Member List
Calendar
Help




