Cdbl & International Settings

  • Thread starter Thread starter michele
  • Start date Start date
M

michele

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
 
Hello michelle,

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

Regards.


"michele" <[email protected]> escribió en el mensaje | 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
 
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
Hello michelle,

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

Regards.


"michele" <[email protected]> escribió en el mensaje
| 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
 
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" <[email protected]> escribió en el mensaje | 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
| | Hello michelle,
|
| Use
| system.globalization.cultureinfo.currentculture.numberformat.numberdecimalseparator
| and numbergroupseparator to indicate the separators you want.
| Instead of CDbl, use Double.Parse, which uses current thread culture
| information.
|
| Regards.
|
|
| "michele" <[email protected]> escribió en el mensaje
| || 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
 
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.Numberformat.NumberDecimalSeparator
= ","
but this property is red-only..

Thanks


"José Manuel Agüero" <chema012 en hotmail.com> ha scritto nel messaggio
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" <[email protected]> escribió en el mensaje
| 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
| | Hello michelle,
|
| Use
|
system.globalization.cultureinfo.currentculture.numberformat.numberdecimalseparator
| and numbergroupseparator to indicate the separators you want.
| Instead of CDbl, use Double.Parse, which uses current thread culture
| information.
|
| Regards.
|
|
| "michele" <[email protected]> escribió en el mensaje
| || 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
 
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.Name

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

System.Threading.Thread.CurrentThread.CurrentCulture = 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" <[email protected]> escribió en el mensaje | 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.Numberformat.NumberDecimalSeparator
| = ","
| but this property is red-only..
|
| Thanks
|
|
| "José Manuel Agüero" <chema012 en hotmail.com> ha scritto nel messaggio
| | 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" <[email protected]> escribió en el mensaje
| || 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
|| || Hello michelle,
||
|| Use
||
| system.globalization.cultureinfo.currentculture.numberformat.numberdecimalseparator
|| and numbergroupseparator to indicate the separators you want.
|| Instead of CDbl, use Double.Parse, which uses current thread culture
|| information.
||
|| Regards.
||
||
|| "michele" <[email protected]> escribió en el mensaje
|| ||| 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
 
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
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.Name

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

System.Threading.Thread.CurrentThread.CurrentCulture = 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" <[email protected]> escribió en el mensaje
| 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.Numberformat.NumberDecimalSeparator
| = ","
| but this property is red-only..
|
| Thanks
|
|
| "José Manuel Agüero" <chema012 en hotmail.com> ha scritto nel messaggio
| | 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" <[email protected]> escribió en el mensaje
| || 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
|| || Hello michelle,
||
|| Use
||
|
system.globalization.cultureinfo.currentculture.numberformat.numberdecimalseparator
|| and numbergroupseparator to indicate the separators you want.
|| Instead of CDbl, use Double.Parse, which uses current thread culture
|| information.
||
|| Regards.
||
||
|| "michele" <[email protected]> escribió en el mensaje
|| ||| 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
 
Back
Top