473,385 Members | 1,372 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,385 software developers and data experts.

FormatCurrency and converting back to a number

I have a field that has been formatted using the vb.net FormatCurrency
method. Now, I need to get the amount back into a regular field so I
can use it for calculations. Is there an easy way to remove the
formatting characters ($,) ?

I suppose I could always use the replace function to remove the $ and
comma, but I wasn't sure if there was any easier way, i.e. Format(...)

TIA,
Mark
Nov 21 '05 #1
5 21795
Mark,

You mean something as this?

Dim a As Decimal = 10.1D
TextBox1.Text = FormatCurrency(a)
Dim b As Decimal = CDec(TextBox1.Text)

Cor

"Mark"
I have a field that has been formatted using the vb.net FormatCurrency
method. Now, I need to get the amount back into a regular field so I
can use it for calculations. Is there an easy way to remove the
formatting characters ($,) ?

I suppose I could always use the replace function to remove the $ and
comma, but I wasn't sure if there was any easier way, i.e. Format(...)

TIA,
Mark

Nov 21 '05 #2
Or even assiging to a decimal should work fine if you have Option Strict Off.

Parsing for a $ sign is always prone to probelms when your program runs on a
system that has a different currency symbol.

Rgds,
Anand
http://www.dotnetindia.com

"Mark" wrote:
I have a field that has been formatted using the vb.net FormatCurrency
method. Now, I need to get the amount back into a regular field so I
can use it for calculations. Is there an easy way to remove the
formatting characters ($,) ?

I suppose I could always use the replace function to remove the $ and
comma, but I wasn't sure if there was any easier way, i.e. Format(...)

TIA,
Mark

Nov 21 '05 #3
Yep. I was trying to use Convert.ToDouble and it was crashing... I
hadn't even thought of using the previous CDbl command....

Many thanks.....
"Cor Ligthert" <no**********@planet.nl> wrote in message news:<us**************@TK2MSFTNGP14.phx.gbl>...
Mark,

You mean something as this?

Dim a As Decimal = 10.1D
TextBox1.Text = FormatCurrency(a)
Dim b As Decimal = CDec(TextBox1.Text)

Cor

"Mark"
I have a field that has been formatted using the vb.net FormatCurrency
method. Now, I need to get the amount back into a regular field so I
can use it for calculations. Is there an easy way to remove the
formatting characters ($,) ?

I suppose I could always use the replace function to remove the $ and
comma, but I wasn't sure if there was any easier way, i.e. Format(...)

TIA,
Mark

Nov 21 '05 #4
On Mon, 6 Sep 2004 05:39:08 -0700, Anand[MVP] wrote:
Or even assiging to a decimal should work fine if you have Option Strict Off.

Parsing for a $ sign is always prone to probelms when your program runs on a
system that has a different currency symbol.

Rgds,
Anand
http://www.dotnetindia.com

"Mark" wrote:


Or just use Decimal.Parse or Double.Parse methods :)

Dim dec As Decimal = Decimal.Parse ("$1,250.25", NumberStyles.Currency)

or

Dim dbl As Double = Double.Parse ("$1,250.25", NumberStyles.Currency)

These methods are aware of currency symbol settings, so you don't have to
worry about the parsing issues involved. I would tend to use
Decimal.Parse, though since Decimal works better with monetary values :)
--
Tom Shelton [MVP]
Nov 21 '05 #5
Mark,

It is not previous, it is one of the methods advised to use because it has
much more power than the single Net methods because there is added
functionality (and because there is no Microsoft indexer involved which can
confuse me) I would not know why not to use them.

It is full dotNet.

Cor


Nov 21 '05 #6

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

Similar topics

3
by: Andrzej Jan Taramina | last post by:
I have a need to convert a number into the character that it represents. For example, if I have: <xsl:variable name="number" select="169"/> I want to be able to convert this to the...
1
by: Donald Firesmith | last post by:
We are converting the OPEN Process Framework Repository (www.donald-firesmith.com) of over 1,100 free open source reusable process components for building development methods for...
3
by: Caesar Augustus | last post by:
Hello Tom, Long time listener, first time caller... I have been working with vb code to automate a salary increase process that not only rounds to the nearest penny but also rounds to the...
7
by: hasanainf | last post by:
Hi all, I have two querys QueryPurchased ProductID Location TotPcs Prod1 Loc1 100 Prod2 Loc1 50 Prod3 Loc1 150 Prod3 Loc3 150
5
by: ljb | last post by:
Does anyone know how to correct or why formatcurrency() places the dollar sign after the number? thanks LJB
2
by: Alex Buell | last post by:
Is there an elegant way of converting strings containing digits between different number bases in C++? I.e.: 10 (base 2) = 2 (base 10) FF (base 16) = 256 (base 10) F (base 16) = 1111 (base 2)...
4
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I am trying to convert the digits to even number so for example if I have 3 digit number, I want it to be 4 digit and If I have 5 digit number, I want it to be 6 digit. How can i...
5
by: girl23 | last post by:
I am using a function prototype to convert month number to month name. basically you ask the compiler to enter int from 1 to 12 and then convert it. printMonth ( number ); is the prototype and...
5
by: mjvm | last post by:
Hi, My database (Access 2003) is split with the back end on the server and each person with a front end that is linked. Over time the computers/laptops are being replaced and almost everyone is on...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...

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.