Convert double to string without loss of digits after zero

Hello,

I'm developing in VB.NET, and confronted with this idiotic problem.
I have a double variable i need to convert to a string.

dim x as double = 152.364484546401
When using Cstr() to convert this double to a string, i lose my last ten digits after zero, leaving me with 152,36.

How can i prevent this kind of truncation?

Thanks,
LVL 2
possekeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DhaestCommented:
       Dim x As Double = 152.364484546401
        Dim y As String = x.ToString()
0
possekeAuthor Commented:
Doesn't seem to work.
Seems such a simple thing, but it turns out wrong every time I try something to solve it...

0
DhaestCommented:
I tested here, and my string contains the same as the double.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

possekeAuthor Commented:
I tested too, in Immediate window:

1.5454545454545.ToString :
gives the result wanted

but when working with a double variable, it's not working anymore:
mydoublevar.Tostring
0
DhaestCommented:
Very strange. I created a new console-application and added those 2 statements and added a breakpoint at the latest line and I saw that it went good.
Did you only try it on the immediate window or also in code with a breakpoint ?
0
possekeAuthor Commented:
I tried it In immediate window and through code with a breakpoint.
I'm not some noob in programming so this is really driving me nuts to be stuck at this kind of problem.

Is this Culture related perhaps?
0
DhaestCommented:
That's a possiblitie.
My double gave me: 152.364484546401
My string gave me: 152,364484546401
0
possekeAuthor Commented:
Lol this sucks, what options do I have to rule out any Culture related dependencies?
0
DhaestCommented:
Perhaps this can help you
Double..::.ToString Method (IFormatProvider)
http://msdn.microsoft.com/en-us/library/shxtf045.aspx
0
possekeAuthor Commented:
Thanks for the help, but nothing new there.
As you can see in the file attached, my double variable contains every digit i need, but when performing the ToString after it, it freaks out.


test.JPG
0
possekeAuthor Commented:
Upgrading this question to 250 points, it seems worth it :)
0
DhaestCommented:
I see that you are creating a sql-query string. Why don't you use a sql-command with parameters. If you do so, you can pass the double-type instead of converting it into a string


Or you can try also:
sqlQuery.append("Arb_aantal = " & changedArtikelBeweging.Arb_aantal)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.