473,405 Members | 2,279 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,405 software developers and data experts.

String (Currency) to Decimal Conversion

Hi there

I'm sure there is a straight forward answer to this but I haven't quite got
there.

If I have a String in Sterling Currency Format and try to convert this to a
Decimal (for arithmetic purposes it works fine).

Sample code (VB.Net):

Dim UK As New CultureInfo("en-GB")
SA.Text = (S1.Text * S2.Text).ToString("c", UK)

Dim decSterling as Decimal = SA.Text

(where S1, S2 and SA are text boxes)

If I run the identical code for Dollars this fails with the exception can't
convert String "$...." to Decimal

Sample Code (VB.Net):

Dim US As New CultureInfo("en-US")

DA.Text = (D1.Text * D2.Text).ToString("c", US)

Dim decDollars as Decimal = DA.Text

(where D1, D2 and DA are text boxes)

Why can I convert a string to decimal when using £ (Sterling) but not $
(Dollars)

Thanks for your help

Martyn Fewtrell

mf*******@networkclub.co.uk


Nov 19 '05 #1
0 1753

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

Similar topics

11
by: Adrian | last post by:
Hi I want to use the following declarations but vb dotnet keeps complaining that currency can't be used because it private ? I have tried it in a module and in the declaration pare same error!...
5
by: AMP | last post by:
Hello, I want to add some variables to a string and this isnt working. textBox1.Text="'BSL version='+ bslVerHi+ bslVerLo"; What am I doing wrong? Thanks Mike
14
by: Scott M. | last post by:
Ok, this is driving me nuts... I am using VS.NET 2003 and trying to take an item out of a row in a loosely-typed dataset and place it in a label as a currency. As it is now, I am getting my...
10
by: TC | last post by:
Hey All, I have strings in currency. For example: "$1.29" What is the best way to convert them to decimal formatted like: "1.29" Thanks, TC
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...
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
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
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.