473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Format Function Not Working with Currency

Hello all! I'm having the oddest issue trying to format a numeric
string as currency without decimals. For instance...

strSalary = "120000.56"

strSalary = Format(strSalary, "$#,##0")
'this one returns "$#,##0" literally, no number

strSalary = Format(strSalary, "C0")
'this one returns "C0" literally, no number

strSalary = Format(strSalary, "currency")
'this one actually formats the number as currency, but is has decimal
places! So close, yet so far...

Am I missing something????

Thanks you,
Cory

Jun 7 '06 #1
2 1563
In order for Format to work the way you want, you must pass in a
numeric type not a string.
strSalary = Format(strSalary, "$#,##0")
'this one returns "$#,##0" literally, no number
Dim dSalary as Decimal = 120000.56
strSalary = Format(strSalary, "$#,##0")

cr********@gmail.com wrote: Hello all! I'm having the oddest issue trying to format a numeric
string as currency without decimals. For instance...

strSalary = "120000.56"

strSalary = Format(strSalary, "$#,##0")
'this one returns "$#,##0" literally, no number

strSalary = Format(strSalary, "C0")
'this one returns "C0" literally, no number

strSalary = Format(strSalary, "currency")
'this one actually formats the number as currency, but is has decimal
places! So close, yet so far...

Am I missing something????

Thanks you,
Cory


Jun 7 '06 #2
Thank you! That's exactly what I needed to know. I simply wrapped the
string variable in the CDbl function and it worked perfectly. I'd
thought you could format strings as numbers so long as the characters
were all numeric such as with the "currency" type.

strSalary = Format(CDbl(strSalary), "C0")

Thanks again!

Jun 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bill Stanard | last post by:
I have had no success using the format function as follows (the two lines of code run one after the other): 'displays a running total of lblAmtdue.Caption 'contents in txtTotal.Text...
4
by: Patrick J. Schouten | last post by:
I am new to ASP/VBScript and I am trying to format a texbox when a user exits it. In Visual Basic you could put the following in the Exit property of the textbox: textbox1 = Format(textbox1,...
2
by: Dalan | last post by:
This should not be an issue, but it is. I'm sure that someone knows what little piece of code is needed too persuade Access 97 to include a currency format for labels (Avery, mailing type). Have...
1
by: Mike MacSween | last post by:
This looks like a bug to me. I have an expression on a report: =Format(Sum((**)*(/)),"0.00") Score is byte PercentOfGrade is double PropDegree is single ModuleCats is byte
2
by: DD | last post by:
I have a UnionQry that is run from StatementsI and StatementP. the Due and Paid colunms are currency and show the $ however when i union the two the currency format has gone. Any help please...
1
by: J.B | last post by:
I have a datagrid that will display different datasets, (it runs different sprocs based on a value in the querystring) but it will always return 6 columns. The 5th and 6th columns are always Date...
1
by: D. Shane Fowlkes | last post by:
I have a DataItem in a Template that calls a Function to perform a calculation. The Function returns a decimal value. Easy enough. It looks like this: <code> <%#...
1
by: Parveen | last post by:
This is a pretty simple issue to solve...but i can't seem to figure it out!! I want data in some columns to show as currency so I set the format of a column to currency through code by ...
16
by: Alexio | last post by:
Am new to javascript. I need to format the currency in the as numbers are entered in textboxes. I can format the currency in the calculations and display in the totals but can not figure out how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.