By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,165 Members | 1,372 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,165 IT Pros & Developers. It's quick & easy.

Cdbl & International Settings

P: n/a
Hi, I have a problem with two function: IsNumber() and CDbl() because when I
invoke it they throw an exception.
The problem I think is International Settings, because
NumberDecimalSeparator and NumberDecimalGroup have the same value "."
I can't change this setting on computer by default so what I want to know if
I can change this settings only for my application.

I've used System.Globalization but CDbl use the settings in contro pannel.

Thanks in advice

Feb 10 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hello michelle,

Use system.globalization.cultureinfo.currentculture.nu mberformat.numberdecimalseparator and numbergroupseparator to indicate the separators you want.
Instead of CDbl, use Double.Parse, which uses current thread culture information.

Regards.
"michele" <mi***********@unipr.it> escribió en el mensaje news:%2****************@TK2MSFTNGP14.phx.gbl...
| Hi, I have a problem with two function: IsNumber() and CDbl() because when I
| invoke it they throw an exception.
| The problem I think is International Settings, because
| NumberDecimalSeparator and NumberDecimalGroup have the same value "."
| I can't change this setting on computer by default so what I want to know if
| I can change this settings only for my application.
|
| I've used System.Globalization but CDbl use the settings in contro pannel.
|
| Thanks in advice

Feb 10 '06 #2

P: n/a
Thank you, in fact I've used it and I thought that all was ok but I
discovered that I used I PrintDocument that involved "International
Settings" and I've the applicationt runs ok but I can't print because I
don't know how to set enviroment to PrintDocument.

"José Manuel Agüero" <chema012 en hotmail.com> ha scritto nel messaggio
news:uA****************@TK2MSFTNGP12.phx.gbl...
Hello michelle,

Use
system.globalization.cultureinfo.currentculture.nu mberformat.numberdecimalseparator
and numbergroupseparator to indicate the separators you want.
Instead of CDbl, use Double.Parse, which uses current thread culture
information.

Regards.
"michele" <mi***********@unipr.it> escribió en el mensaje
news:%2****************@TK2MSFTNGP14.phx.gbl...
| Hi, I have a problem with two function: IsNumber() and CDbl() because when
I
| invoke it they throw an exception.
| The problem I think is International Settings, because
| NumberDecimalSeparator and NumberDecimalGroup have the same value "."
| I can't change this setting on computer by default so what I want to know
if
| I can change this settings only for my application.
|
| I've used System.Globalization but CDbl use the settings in contro pannel.
|
| Thanks in advice
Feb 10 '06 #3

P: n/a
I don't understand the problem. The PrintPage event runs on the same thread on which you call PrintDocument.Print, so it uses the same environment.

Regards.
"michele" <mi*****@zenna.it> escribió en el mensaje news:OR**************@TK2MSFTNGP11.phx.gbl...
| Thank you, in fact I've used it and I thought that all was ok but I
| discovered that I used I PrintDocument that involved "International
| Settings" and I've the applicationt runs ok but I can't print because I
| don't know how to set enviroment to PrintDocument.
|
| "José Manuel Agüero" <chema012 en hotmail.com> ha scritto nel messaggio
| news:uA****************@TK2MSFTNGP12.phx.gbl...
| Hello michelle,
|
| Use
| system.globalization.cultureinfo.currentculture.nu mberformat.numberdecimalseparator
| and numbergroupseparator to indicate the separators you want.
| Instead of CDbl, use Double.Parse, which uses current thread culture
| information.
|
| Regards.
|
|
| "michele" <mi***********@unipr.it> escribió en el mensaje
| news:%2****************@TK2MSFTNGP14.phx.gbl...
|| Hi, I have a problem with two function: IsNumber() and CDbl() because when
| I
|| invoke it they throw an exception.
|| The problem I think is International Settings, because
|| NumberDecimalSeparator and NumberDecimalGroup have the same value "."
|| I can't change this setting on computer by default so what I want to know
| if
|| I can change this settings only for my application.
||
|| I've used System.Globalization but CDbl use the settings in contro pannel.
||
|| Thanks in advice

Feb 11 '06 #4

P: n/a
Ok, maybe I missunderstand how to program so can you explain more, it it is
possible.
I've tried to use
System.Globalization.Cultureinfo.Currentculture.Nu mberformat.NumberDecimalSeparator
= ","
but this property is red-only..

Thanks
"José Manuel Agüero" <chema012 en hotmail.com> ha scritto nel messaggio
news:eQ**************@TK2MSFTNGP10.phx.gbl...
I don't understand the problem. The PrintPage event runs on the same thread
on which you call PrintDocument.Print, so it uses the same environment.

Regards.
"michele" <mi*****@zenna.it> escribió en el mensaje
news:OR**************@TK2MSFTNGP11.phx.gbl...
| Thank you, in fact I've used it and I thought that all was ok but I
| discovered that I used I PrintDocument that involved "International
| Settings" and I've the applicationt runs ok but I can't print because I
| don't know how to set enviroment to PrintDocument.
|
| "José Manuel Agüero" <chema012 en hotmail.com> ha scritto nel messaggio
| news:uA****************@TK2MSFTNGP12.phx.gbl...
| Hello michelle,
|
| Use
|
system.globalization.cultureinfo.currentculture.nu mberformat.numberdecimalseparator
| and numbergroupseparator to indicate the separators you want.
| Instead of CDbl, use Double.Parse, which uses current thread culture
| information.
|
| Regards.
|
|
| "michele" <mi***********@unipr.it> escribió en el mensaje
| news:%2****************@TK2MSFTNGP14.phx.gbl...
|| Hi, I have a problem with two function: IsNumber() and CDbl() because
when
| I
|| invoke it they throw an exception.
|| The problem I think is International Settings, because
|| NumberDecimalSeparator and NumberDecimalGroup have the same value "."
|| I can't change this setting on computer by default so what I want to know
| if
|| I can change this settings only for my application.
||
|| I've used System.Globalization but CDbl use the settings in contro
pannel.
||
|| Thanks in advice
Feb 11 '06 #5

P: n/a
Yes, michele, the CultureInfo returned by System.Globalization.Cultureinfo.Currentculture is read only. You must replace it. Look at this sample:

Sub Main()

Dim s as String = System.Globalization.CultureInfo.CurrentCulture.Na me

Dim ci As New System.Globalization.CultureInfo(s, True)

System.Threading.Thread.CurrentThread.CurrentCultu re = ci

ci.NumberFormat.NumberDecimalSeparator = ","

Debug.WriteLine(Double.Parse("3,14") * 10)

ci.NumberFormat.NumberDecimalSeparator = "·"

'Debug.WriteLine(Double.Parse("3,14") * 10) 'Error: "," is not part of a number.

Debug.WriteLine(Double.Parse("3·14") * 10)

End Sub

Regards.

"michele" <mi*****@zenna.it> escribió en el mensaje news:%2****************@TK2MSFTNGP14.phx.gbl...
| Ok, maybe I missunderstand how to program so can you explain more, it it is
| possible.
| I've tried to use
| System.Globalization.Cultureinfo.Currentculture.Nu mberformat.NumberDecimalSeparator
| = ","
| but this property is red-only..
|
| Thanks
|
|
| "José Manuel Agüero" <chema012 en hotmail.com> ha scritto nel messaggio
| news:eQ**************@TK2MSFTNGP10.phx.gbl...
| I don't understand the problem. The PrintPage event runs on the same thread
| on which you call PrintDocument.Print, so it uses the same environment.
|
| Regards.
|
|
| "michele" <mi*****@zenna.it> escribió en el mensaje
| news:OR**************@TK2MSFTNGP11.phx.gbl...
|| Thank you, in fact I've used it and I thought that all was ok but I
|| discovered that I used I PrintDocument that involved "International
|| Settings" and I've the applicationt runs ok but I can't print because I
|| don't know how to set enviroment to PrintDocument.
||
|| "José Manuel Agüero" <chema012 en hotmail.com> ha scritto nel messaggio
|| news:uA****************@TK2MSFTNGP12.phx.gbl...
|| Hello michelle,
||
|| Use
||
| system.globalization.cultureinfo.currentculture.nu mberformat.numberdecimalseparator
|| and numbergroupseparator to indicate the separators you want.
|| Instead of CDbl, use Double.Parse, which uses current thread culture
|| information.
||
|| Regards.
||
||
|| "michele" <mi***********@unipr.it> escribió en el mensaje
|| news:%2****************@TK2MSFTNGP14.phx.gbl...
||| Hi, I have a problem with two function: IsNumber() and CDbl() because
| when
|| I
||| invoke it they throw an exception.
||| The problem I think is International Settings, because
||| NumberDecimalSeparator and NumberDecimalGroup have the same value "."
||| I can't change this setting on computer by default so what I want to know
|| if
||| I can change this settings only for my application.
|||
||| I've used System.Globalization but CDbl use the settings in contro
| pannel.
|||
||| Thanks in advice

Feb 12 '06 #6

P: n/a
Thanks, I write my code with you suggestion and now I thinks that it works
fine but tomorrow I test my application and then I'll tell you if all run.
Thank you again, sincerly Michele

"José Manuel Agüero" <chema012 en hotmail.com> ha scritto nel messaggio
news:eo**************@TK2MSFTNGP11.phx.gbl...
Yes, michele, the CultureInfo returned by
System.Globalization.Cultureinfo.Currentculture is read only. You must
replace it. Look at this sample:

Sub Main()

Dim s as String = System.Globalization.CultureInfo.CurrentCulture.Na me

Dim ci As New System.Globalization.CultureInfo(s, True)

System.Threading.Thread.CurrentThread.CurrentCultu re = ci

ci.NumberFormat.NumberDecimalSeparator = ","

Debug.WriteLine(Double.Parse("3,14") * 10)

ci.NumberFormat.NumberDecimalSeparator = "·"

'Debug.WriteLine(Double.Parse("3,14") * 10) 'Error: "," is not part
of a number.

Debug.WriteLine(Double.Parse("3·14") * 10)

End Sub

Regards.

"michele" <mi*****@zenna.it> escribió en el mensaje
news:%2****************@TK2MSFTNGP14.phx.gbl...
| Ok, maybe I missunderstand how to program so can you explain more, it it
is
| possible.
| I've tried to use
|
System.Globalization.Cultureinfo.Currentculture.Nu mberformat.NumberDecimalSeparator
| = ","
| but this property is red-only..
|
| Thanks
|
|
| "José Manuel Agüero" <chema012 en hotmail.com> ha scritto nel messaggio
| news:eQ**************@TK2MSFTNGP10.phx.gbl...
| I don't understand the problem. The PrintPage event runs on the same
thread
| on which you call PrintDocument.Print, so it uses the same environment.
|
| Regards.
|
|
| "michele" <mi*****@zenna.it> escribió en el mensaje
| news:OR**************@TK2MSFTNGP11.phx.gbl...
|| Thank you, in fact I've used it and I thought that all was ok but I
|| discovered that I used I PrintDocument that involved "International
|| Settings" and I've the applicationt runs ok but I can't print because I
|| don't know how to set enviroment to PrintDocument.
||
|| "José Manuel Agüero" <chema012 en hotmail.com> ha scritto nel messaggio
|| news:uA****************@TK2MSFTNGP12.phx.gbl...
|| Hello michelle,
||
|| Use
||
|
system.globalization.cultureinfo.currentculture.nu mberformat.numberdecimalseparator
|| and numbergroupseparator to indicate the separators you want.
|| Instead of CDbl, use Double.Parse, which uses current thread culture
|| information.
||
|| Regards.
||
||
|| "michele" <mi***********@unipr.it> escribió en el mensaje
|| news:%2****************@TK2MSFTNGP14.phx.gbl...
||| Hi, I have a problem with two function: IsNumber() and CDbl() because
| when
|| I
||| invoke it they throw an exception.
||| The problem I think is International Settings, because
||| NumberDecimalSeparator and NumberDecimalGroup have the same value "."
||| I can't change this setting on computer by default so what I want to
know
|| if
||| I can change this settings only for my application.
|||
||| I've used System.Globalization but CDbl use the settings in contro
| pannel.
|||
||| Thanks in advice
Feb 12 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.