Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 538
  • Last Modified:

FormatCurrency help

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
Ladmo
Asked:
Ladmo
1 Solution
 
aelatikCommented:
FormatCurrency(rsRecordset("FieldName"),2)

0
 
mgfranzCommented:
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
 
LadmoAuthor Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
mgfranzCommented:
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
 
pseudolusCommented:
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
 
LadmoAuthor Commented:
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
 
AlfaNoMoreCommented:
Tyr closing this question first! points possibly to mgfranz?
0
 
GaryCommented:
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
 
mgfranzCommented:
nah... incomplete.  I think my comment covers it better.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now