473,395 Members | 1,335 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,395 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 21797
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...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.