Home All Groups Group Topic Archive Search About

string to double try parse ---decimals lost

Author
1 Feb 2006 8:28 PM
Clarkie
Hi!

I have a string that I try to convert into a double

        Dim dblOrgAmount As Integer
        Dim sLine as string
        Dim blnSuccess As Boolean
blnSuccess = Double.TryParse(sLine.Substring(65, 15), dblOrgAmount)

The problem is that dblOrgAmount does not contain any decimals, though the
string does.
EG
-8967676.675 ---->    -8967677

I am using "en-US" as culture for the current thread.

Any ideas?

Author
1 Feb 2006 8:36 PM
Armin Zingler
Show quote Hide quote
"Clarkie" <clarkbo***@rock.sendmenot.etmail.com> schrieb
> Hi!
>
> I have a string that I try to convert into a double
>
>        Dim dblOrgAmount As Integer
>        Dim sLine as string
>        Dim blnSuccess As Boolean
> blnSuccess = Double.TryParse(sLine.Substring(65, 15), dblOrgAmount)
>
> The problem is that dblOrgAmount does not contain any decimals,
> though the string does.
> EG
> -8967676.675 ---->    -8967677
>
> I am using "en-US" as culture for the current thread.
>
> Any ideas?


Enable Option Strict.


Armin
Author
1 Feb 2006 8:53 PM
Herfried K. Wagner [MVP]
"Clarkie" <clarkbo***@rock.sendmenot.etmail.com> schrieb:
> I have a string that I try to convert into a double
>
>        Dim dblOrgAmount As Integer

=> 'Dim dblOrgAmount As Double'-

Show quoteHide quote
>        Dim sLine as string
>        Dim blnSuccess As Boolean
> blnSuccess = Double.TryParse(sLine.Substring(65, 15), dblOrgAmount)
>
> The problem is that dblOrgAmount does not contain any decimals, though the
> string does.
> EG
> -8967676.675 ---->    -8967677
>
> I am using "en-US" as culture for the current thread.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
1 Feb 2006 8:57 PM
Clarkie
What a mistake!

I should get some sleep I guess!

Thanks!

Clarkie
Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:%23rHWLG3JGHA.3912@TK2MSFTNGP10.phx.gbl...
> "Clarkie" <clarkbo***@rock.sendmenot.etmail.com> schrieb:
>> I have a string that I try to convert into a double
>>
>>        Dim dblOrgAmount As Integer
>
> => 'Dim dblOrgAmount As Double'-
>
>>        Dim sLine as string
>>        Dim blnSuccess As Boolean
>> blnSuccess = Double.TryParse(sLine.Substring(65, 15), dblOrgAmount)
>>
>> The problem is that dblOrgAmount does not contain any decimals, though
>> the string does.
>> EG
>> -8967676.675 ---->    -8967677
>>
>> I am using "en-US" as culture for the current thread.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>