473,804 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to convert "1.12" to double

13 New Member
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 1446
Plater
7,872 Recognized Expert Expert
Have you tried:
Expand|Select|Wrap|Line Numbers
  1. Dim MyDouble as double
  2. MyDouble = double.Parse("1.2")
  3.  
Oct 24 '07 #2
nadeaupn
13 New Member
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 Recognized Expert Expert
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
nadeaupn
13 New Member
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 Recognized Expert Expert
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.ToStri ng() to something similar to what I used for the .Parse() so that it prints using a "." instead of a ","
Oct 24 '07 #6
nadeaupn
13 New Member
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
2786
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"> <!-- window.open ('photos01.html','photogallery',config='height=550, width=750,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');
3
2317
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
16555
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 want the result of shortVal = 3000 and store as short instead of double
7
30793
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 along. It says it's an invalid cast. However, if I use the Convert.ToInt32() method (for example) things will work. At least, that's how it appears to me. Could someone explain when to use old-style parenthesized casts vs. the Convert() methods?
2
6863
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 as a value. Check out the following problem. I want to convert the value in <WpDatesXml> node to have a valid "<" and ">" instead of &lt or &gt format so that I can use this xml for another use. Please help! <NewDataSet> <Table1>
5
36878
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? For example, I write the code shown below: Dim DblA as double = 999999999999999.12 Dim VarA As String = FormatNumber(DblA) The result of VarA contains value "999999999999999.00" instead of "999999999999999.12".
0
1184
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
16493
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
7526
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. sprintf (and its brothers) 3. any nonstandard C/C++ functions
0
9595
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9177
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6870
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3005
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.