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
6 1421
Have you tried: -
Dim MyDouble as double
-
MyDouble = double.Parse("1.2")
-
Yes I did and it does not work as well.
Thank you for trying to help.
Regards,
Pierre
How about : -
Dim MyDouble as double
-
Dim nfi As New System.Globalization.NumberFormatInfo()
-
nfi.NumberDecimalSeparator = "."
-
MyDouble = Double.Parse("1.2", System.Globalization.NumberStyles.AllowDecimalPoint, nfi)
-
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
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 ","
Hi Plater,
With your code lines + your comments, I succeeded.
Thanks a lot for your help.
Regards,
Pierre
Sign in to post your reply or Sign up for a free account.
Similar topics
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">
<!--...
|
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();
|
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...
|
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...
|
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 < and > format if
it's > or < tag.
Since I have sub xml data in a parent xml node...
|
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?
...
|
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
|
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={ ?, ?, ?, ?, ?, ?,...
|
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....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
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...
|
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...
|
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: 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...
|
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...
| |