?
Solved

FormatCurrency help

Posted on 2003-03-18
10
Medium Priority
?
535 Views
Last Modified: 2008-03-17
I'm trying to format a table field returned from a query.  the field is formatted as decimal and i'm trying to change it to currency

I have this code to populate the table for the "Price" field.  I can change fonts for the field, make it bold, change it back but cannot for the life of me figure out how to use the FormatCurrency function:

Response.Write "<td borderColorDark=#f0f0f0 borderColorLight=#000000 valign=TOP class=""eTableData""><b>" & CellString(rs1(3)) & "</b></a></td>"

Lon Thomas
0
Comment
Question by:Ladmo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 14

Accepted Solution

by:
aelatik earned 200 total points
ID: 8160773
FormatCurrency(rsRecordset("FieldName"),2)

0
 
LVL 18

Expert Comment

by:mgfranz
ID: 8160800
What is in the CellString function?

Anyway, everything you will ever need to know about FormatCurrency;

FUNCTION:  FormatCurrency( )

--------------------------------------------------------------
Implemented in version 2.0
 
FormatCurrency(Expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, GroupDigit)
 
The FormatCurrency function return a formatted currency value for the numeric expression.
 
There is one mandatory argument.
 
Expression
 
The Expression argument is the number to be converted to a currency format.
 
Code:
<% =FormatCurrency(31567) %>
 
Output:
$31,567.00
 
Note that this function rounds off values.
 
Code:
<% =FormatCurrency(31567.8977) %>
 
Output:
$31,567.90
 
There are 4 optional arguments.
 
NumDigitsAfterDecimal
The optional NumDigitsAfterDecimal argument allows you to choose the number of digits after the decimal.
 
Code:
<% =FormatCurrency(31567, 2) %>
 
Output:
$31,567.00
 
IncludeLeadingDigit
 
The optional IncludeLeadingDigit argument includes the leading zero.
 
You must only use the constant or value from the Tristate CONSTANTS for this argument.
 
CONSTANT VALUE DESCRIPTION
TristateTrue -1 True, will use options
TristateFalse  0 False, will not use options
TristateUseDefault -2 Use default setting
 
Code:
<% =FormatCurrency(.77, 2, -1) %>
 
Output:
$0.77
 
UseParensForNegativeNumbers
 
The optional UseParensForNegativeNumber argument replaces a negative sign with parentheses around the number.
 
You must only use the constant or value from the Tristate CONSTANTS for this argument.
 
CONSTANT VALUE DESCRIPTION
TristateTrue -1 True, will use options
TristateFalse  0 False, will not use options
TristateUseDefault -2 Use default setting
 
Code:
<% =FormatCurrency(-31567, 2, 0, -1) %>
 
Output:
($31,567.00)
 
GroupDigit
 
The optional GroupDigit argument allows the use of the options specified in the Currency tab in the Regional Settings Properties in the Control Panel.
 
You must only use the constant or value from the Tristate CONSTANTS for this argument.
 
CONSTANT VALUE DESCRIPTION
TristateTrue -1 True, will use options
TristateFalse  0 False, will not use options
TristateUseDefault -2 Use default setting
 
Code:
<% =FormatCurrency(31567, 2, 0, -1, -1) %>
 
Output:
$31,567.00
0
 

Author Comment

by:Ladmo
ID: 8160805
thanks!  dumb question, though.  where do i put it?  within hat line of code I posted???

sorry, i'm trying to do a hacked fix on something.  i'm not a clever programmer :)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:mgfranz
ID: 8160849
Without knowing what's in CellString, try this;

Response.Write "<td borderColorDark=#f0f0f0 borderColorLight=#000000 valign=TOP class=""eTableData""><b>" & FormatCurrency(CellString(rs1(3)), 2) & "</b></a></td>"
0
 

Expert Comment

by:pseudolus
ID: 8161041
Returns an expression formatted as a currency value using the currency symbol defined in the system control panel.

FormatCurrency(Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])
Arguments
Expression
Required. Expression to be formatted.
NumDigitsAfterDecimal
Optional. Numeric value indicating how many places to the right of the decimal are displayed. Default value is -1, which indicates that the computer's regional settings are used.
IncludeLeadingDigit
Optional. Tristate constant that indicates whether or not a leading zero is displayed for fractional values. See Settings section for values.
UseParensForNegativeNumbers
Optional. Tristate constant that indicates whether or not to place negative values within parentheses. See Settings section for values.
GroupDigits
Optional. Tristate constant that indicates whether or not numbers are grouped using the group delimiter specified in the computer's regional settings. See Settings section for values.
Settings
The IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits arguments have the following settings:

Constant Value Description
TristateTrue -1 True
TristateFalse 0 False
TristateUseDefault -2 Use the setting from the computer's regional settings.

Remarks
When one or more optional arguments are omitted, values for omitted arguments are provided by the computer's regional settings. The position of the currency symbol relative to the currency value is determined by the system's regional settings.

Note   All settings information comes from the Regional Settings Currency tab, except leading zero, which comes from the Number tab.
The following example uses the FormatCurrency function to format the expression as a currency and assign it to MyCurrency:

Dim MyCurrency
MyCurrency = FormatCurrency(1000)   ' MyCurrency contains $1000.00.
0
 

Author Comment

by:Ladmo
ID: 8161190
Thanks!  I now have currency!  I tried similar attempts in that area, but my syntax was just a skosh off!

Well, I'm off to discover more knowledge deficiencies!

Lon
0
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 8165490
Tyr closing this question first! points possibly to mgfranz?
0
 
LVL 58

Expert Comment

by:Gary
ID: 9315910
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Answer by aelatik

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 9320473
nah... incomplete.  I think my comment covers it better.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question