Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mix up in CultureInfo
Message
De
08/09/2015 13:56:58
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Mix up in CultureInfo
Versions des environnements
Environment:
VB 9.0
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01624382
Message ID:
01624382
Vues:
62
My framework main application class is defining those properties:
    Public oCultureInfoEnglish As CultureInfo = Nothing
    Public oCultureInfoFrench As CultureInfo = Nothing
    Public oCultureInfoSpanish As CultureInfo = Nothing
    Public oCultureInfoPortuguese As CultureInfo = Nothing
The values are this:
        oCultureInfoEnglish = New CultureInfo("en-US")
        oCultureInfoFrench = New CultureInfo("fr-CA")
        oCultureInfoSpanish = New CultureInfo("en-US")
        oCultureInfoPortuguese = New CultureInfo("en-US")
I have a function to display a numeric value as follow:
    ' Format a value
    ' expN1 Value
    ' expC1 Separator
    ' expN2 Number of decimals
    Public Function GetFormatValue(ByVal tnValue As Double, ByVal tcSeparator As String, _
     ByVal tnDecimal As Integer) As String
        Dim lcValue As String = ""
        Dim loCultureInfo As CultureInfo = Nothing

        ' Based on the language
        Select Case nLanguage

            ' English
            Case 1
                loCultureInfo = oApp.oCultureInfoEnglish

                ' French
            Case 2
                loCultureInfo = oApp.oCultureInfoFrench

                ' Spanish
            Case 3
                loCultureInfo = oApp.oCultureInfoSpanish

                ' Portuguese
            Case 4
                loCultureInfo = oApp.oCultureInfoPortuguese

        End Select

        loCultureInfo.NumberFormat.NumberDecimalSeparator = "."
        loCultureInfo.NumberFormat.NumberGroupSeparator = tcSeparator
        loCultureInfo.NumberFormat.NumberDecimalDigits = tnDecimal

        lcValue = tnValue.ToString("N", loCultureInfo)

        Return lcValue
    End Function
On some very rare situations, I have found that my value is being shown such as 30.000 where it should be 30.

There seems to be a mixup of the memory in the usage of this culture info.

My method receives 0 for the tnDecimal parameter. So, by looking at this method, it should be displayed 30 and not 30.000. The only time I should have decimals is if the method receives 3, for example, as the tnDecimal parameter value, which would then end up with 30.000.

As this is random, and on a very rare occasions, I am assuming this is a memory issue. I cannot reproduce this. I have observed this twice and at first I thought I had seen it wrong. But, when I saw it a second time, I figured something is wrong.

Anyone would know what could be wrong here?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform