473,395 Members | 1,456 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.

Trying to convert "1.12" to double

Trying to convert "1.12" to double :

Dim MyDouble as double
MyDouble = cdbl("1.2")

I obtain the following error message :

"La conversion de la chaîne "1.2" en type 'Double' n'est pas valide."

"Conversion of string "1.2" to double is invalid"

I have setted my international parameters in order to have the point (.) as my decimal setting. My other software on my computer understand "1.2" (Excel, Simply accounting...).

I am using Visual Studio 2005 and VB as my coding.

Please help me.

Regards,

Pierre
Oct 24 '07 #1
6 1421
Plater
7,872 Expert 4TB
Have you tried:
Expand|Select|Wrap|Line Numbers
  1. Dim MyDouble as double
  2. MyDouble = double.Parse("1.2")
  3.  
Oct 24 '07 #2
Yes I did and it does not work as well.

Thank you for trying to help.

Regards,

Pierre
Oct 24 '07 #3
Plater
7,872 Expert 4TB
How about:
Expand|Select|Wrap|Line Numbers
  1. Dim MyDouble as double
  2. Dim nfi As New System.Globalization.NumberFormatInfo() 
  3. nfi.NumberDecimalSeparator = "." 
  4. MyDouble = Double.Parse("1.2", System.Globalization.NumberStyles.AllowDecimalPoint, nfi) 
  5.  
Oct 24 '07 #4
Hi PLater,

It partially works.

I do not have an error message and my string is converted to a double value, but this double value is 1,2 instead of 1.2.

My objective is as the following :

1- The possibility for the user to enter a value like 1.2
2- Save this value in a SQL Server field which is configured as real

SQL server does not accept 1,2, it accepts 1.2. When I convert 1.2 to double, if I obtain 1,2, it does not work. Consequently, the double value obtained must be 1.2.

Do you see a solution ?

Regards,

Pierre
Oct 24 '07 #5
Plater
7,872 Expert 4TB
Double values are not stored with a "." or a "," it's all how you present them with .ToString() and such.
either use a stored procedure that will take a double as a double, or change your myDouble.ToString() to something similar to what I used for the .Parse() so that it prints using a "." instead of a ","
Oct 24 '07 #6
Hi Plater,

With your code lines + your comments, I succeeded.

Thanks a lot for your help.

Regards,

Pierre
Oct 25 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Michael Stevens | last post by:
Probably the wrong wording but since I'm not a scripter I won't claim to know what I'm talking about. I got this script from www.htmlgoodies.com <script language="JavaScript"> <!--...
3
by: jeff_zhang446 | last post by:
Hi, I try to convert double to string as below: std::string cnvrtToString(double lValue) { std::ostringstream lStream; lStream << lValue; return lStream.str();
12
by: Alan | last post by:
how to convert double to short ? for example, I want to convert double doubleVal1 = 15000.1; double doubleVal2 = 12000.0; short shortVal; shortVal = doubleVal1 - doubleVal2; I...
7
by: Jim Bancroft | last post by:
Hi everyone, A basic one here, I think. I haven't found the pattern yet, but sometimes when I cast a variable to another type using the "C" style cast operator the compiler refuses to play...
2
by: andrew007 | last post by:
I do xml / xslt transformation using asp.net but I found any value (w/xml format) in xml node html-encoded to &lt and &gt format if it's > or < tag. Since I have sub xml data in a parent xml node...
5
by: Steven | last post by:
I have tried to use FormatNumber() to convert a very large double type number to String format, however, the result seems not correct, is there any limitation for using FormatNumber() function? ...
0
by: aparna12 | last post by:
Hi all Please tell me how to Convert double to string in fraction format (.75 to 3/4) in asp.net. Thanks Aparna
1
by: =?big5?B?qM6nuw==?= | last post by:
I already knew how to convert bytes to Double, use BitConverter.ToDouble(). but, How to convert double to bytes? for example: double a = 3,444; I want convert to bytes={ ?, ?, ?, ?, ?, ?,...
21
by: Aman JIANG | last post by:
hi I need to do this (convert double to string) fast, safe and portable. Is there any way to do this ? Except the ways following: 1. C++ I/O stream, stringstream (and boost::lexical_cast) 2....
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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...
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...

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.