Resolved problem

andrews

Well-known member
Joined
Nov 22, 2011
Messages
146
Programming Experience
5-10
I do not understand why
in a sub i have written
VB.NET:
dim w as double
dim nm as string
nm = "5.2356"
w = cdbl(nm)
but i see in de debug that w = 5000 ?
what do i wrong ?
Thanks for any response
 
Last edited by a moderator:
Solution
You said in post #1 that nm was "5.2356" and that w was 5000 but the screenshot you provided shows that nm is "5.000" and doesn't show any value for w. It doesn't show a value for i either, so we can only guess which item/element of rijrecords is being set on the current iteration, but it looks like it's rijrecords(2), which has a value of 5000. Converting "5.000" to a Double will depend on what the current culture is. If the current culture uses a period as a decimal point then it will convert to 5 and if it uses a comma as a decimal point then it will convert to 5000. I don't know what Belgian uses so you'll have to check. I...
Firstly, please provide a descriptive title for all threads. Your title is as good as no title at all. Secondly, please don't post unformatted code snippets, as they are unnecessarily hard to read. This one's not a big deal but others may be worse, so just always format them to help us help you.
 
As for the issue, your current culture could change how the comma is interpreted but I don't see how that code could produce 5000 either way. Can you please provide a screenshot showing that code with a breakpoint immediately after and the contents of the Autos or Locals window?
 
As for the issue, your current culture could change how the comma is interpreted but I don't see how that code could produce 5000 either way. Can you please provide a screenshot showing that code with a breakpoint immediately after and the contents of the Autos or Locals window?

I used point and comma without result
for i = 1 with a comma i get 5 for nm = 5,000
the culture is belgian
Schermafbeelding 2024-06-14 181224.jpg

see now the screenshot
 
You said in post #1 that nm was "5.2356" and that w was 5000 but the screenshot you provided shows that nm is "5.000" and doesn't show any value for w. It doesn't show a value for i either, so we can only guess which item/element of rijrecords is being set on the current iteration, but it looks like it's rijrecords(2), which has a value of 5000. Converting "5.000" to a Double will depend on what the current culture is. If the current culture uses a period as a decimal point then it will convert to 5 and if it uses a comma as a decimal point then it will convert to 5000. I don't know what Belgian uses so you'll have to check. I know French uses a comma as a decimal point so Belgian may be the same. Take a look at CultureInfo.CurentCulture.NumberFormat.NumberDecimalSeparator and .NumberGroupSeparator to see. I suspect that the former will be "," and the latter will be ".", in which case what you're seeing appears to be exactly what you would expect.
 
Solution

Latest posts

Back
Top