473,670 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(strSalar y, "$#,##0")
'this one returns "$#,##0" literally, no number

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

strSalary = Format(strSalar y, "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 1577
In order for Format to work the way you want, you must pass in a
numeric type not a string.
strSalary = Format(strSalar y, "$#,##0")
'this one returns "$#,##0" literally, no number
Dim dSalary as Decimal = 120000.56
strSalary = Format(strSalar y, "$#,##0")

cr********@gmai l.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(strSalar y, "$#,##0")
'this one returns "$#,##0" literally, no number

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

strSalary = Format(strSalar y, "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(str Salary), "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
8845
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 txtTotal.Text = lblAmtdue.Caption + Val(txtTotal.Text) 'tries to format contents of txtTotal.Text as currency; doesn't work txtTotal.Text = Format$(txtTotal.Text, "Currency")
4
14567
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, "Currency") Is this possible in ASP/VbScript? Any help appreciated. Please show code in your reply, especially where to put this code in the asp page? Thanks.
2
9602
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 had no problems with currency formatting on reports - just the labels. Doesn't matter if the associated field in the Table and Form have Format as Currency, because on the labels (for instance $50.00) prints as: 50 The only way to get it to print...
1
15471
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
2227
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 SELECT * FROM qryStatementI UNION SELECT * FROM qryStatementP ORDER BY thedate;
1
2309
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 and Currency format, all others are strings. I'd like to build one datagrid to handle this datagrid dynamically. I have it working now, all except the formatting of the 5th (Date) and 6th (Currency) columns. Since the headers for those...
1
2014
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> <%# CalculateExpended(Container.DataItem("StaffID")) %> </code> So how exactly can I format this to come out as currency? I can NOT format the output in the function. The function must return a decimal. I've tried
1
1519
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 myGrid.cols(ColIndex).format = "c Then I manually add rows to the grid...but when I look at the currency column, I see that the data is not formatted - it still shows up as a numeric value without the "$" sign
16
12051
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 format in input textboxes. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html;...
0
8384
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8813
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8591
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7412
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6212
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.