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

Convert.ToDouble ?

Hello
i have problems with this function, always thru exception
for all data, for example: Convert.ToDouble("545.0"). Why ?

I want to convert string data in different format into double,
i have formats like:
37.439351
2.00000e+02

How can i do it most easily ?

Thanx
Michal

Nov 16 '05 #1
3 4698
us**@domain.invalid wrote:
Hello
i have problems with this function, always thru exception
for all data, for example: Convert.ToDouble("545.0"). Why ?

I want to convert string data in different format into double,
i have formats like:
37.439351
2.00000e+02

How can i do it most easily ?


What exception are you getting? The above should work fine so we need
details around the exception and what else is going on.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.

Nov 16 '05 #2
Hi Michal,

<us**@domain.invalid> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hello
i have problems with this function, always thru exception
for all data, for example: Convert.ToDouble("545.0"). Why ?

I want to convert string data in different format into double,
i have formats like:
37.439351
2.00000e+02

How can i do it most easily ?

Thanx
Michal


The only reason I can figure that the above code would cause an
exception is if the number is not in a valid format for your current
culture. If you specify the invariant culture does it still cause an
exception?:

double val = Convert.ToDouble("545.0", CultureInfo.InvariantCulture);

CultureInfo is in the System.Globalization namespace.

Regards,
Daniel
Nov 16 '05 #3
Hi,

<us**@domain.invalid> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hello
i have problems with this function, always thru exception
for all data, for example: Convert.ToDouble("545.0"). Why ?


Is it possible that your decimal separator is not '.'?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com
Nov 16 '05 #4

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

Similar topics

4
by: cindy liu | last post by:
Hi, In .Net, how to convert a string to a double? Thanks in advance! Cindy
4
by: Irepan | last post by:
does anybody know how to change the global IFormatProvider of my project so everycall to Convert.ToDouble on it uses this format provider instead of the one the one on the computer's regional...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
10
by: | last post by:
Hey I am calling Convert.ToDouble(someString); But this double can have to ways or representing doubles dependant on the locale, it can be 1.0 or 1,0 Is there a way to make...
3
by: user | last post by:
Hello i have problems with this function, always thru exception for all data, for example: Convert.ToDouble("545.0"). Why ? I want to convert string data in different format into double, i have...
4
by: Daniel Walzenbach | last post by:
Hi, I wonder if somebody could explain me the difference between Double.Parse and Convert.ToDouble. If I'm not mistaken they are implemented differently (I though for a moment they might be the same...
2
by: Jason | last post by:
In VB.NET, when I use System.Convert.ToDouble(string Val) to convert a string variable to double variable, I got something interesting: Dim stringVal As String = "101.01" Dim doubleVal As Double...
4
by: Edwin Knoppert | last post by:
In my code i use the text from a textbox and convert it to a double value. I was using Convert.ToDouble() but i'm used to convert comma to dot. This way i can assure the text is correct. However...
3
by: mrajanikrishna | last post by:
Hi Friends, I am accepting a number from the user entered in a textbox. I want to assign to a variable in my code and assignt this to that variable. double num1 = (double)txtNum1.text; ...
2
by: trondhuso | last post by:
Hi group, I've found some code that I want to use in a project that I am working on, but the code is for c# .net and not 2003 or 2005 that I have available. In this code the program yells on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...

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.