How do I know the language my system is using?

APires

New Member
Joined
Oct 19, 2014
Messages
5
Hello guys,

I am writting a code for which I use numbers with decimal and thousand separators.

I am facing a problem on the comma Vs dot criteria for different regional settings.

If I could use the system language as a variable this problem would be solved as I could manipulate the user input taking into account the system language with a simple IF function.

Is there anyway I can know the system language in the code to be able to use it as a variable afterwards?

I tried to use ENVIRON function but I am definetively missing something here.

Really apreciate your help,

Pires
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
You can ask Excel to tell you what it thinks they are...

DP = Application.DecimalSeparator

TS = Application.ThousandsSeparator
 
Upvote 0
Something old, not my work thou so credit the auther

jiuk
Code:
 Sub GetXlLang()
        Dim lngCode As Long
        lngCode = Application.LanguageSettings.LanguageID(msoLanguageIDUI)
        MsgBox "Code is: " & lngCode & vbNewLine & GetTxt(lngCode)
    End Sub

    Function GetTxt(ByVal lngCode) As String
        Dim objXmlHTTP As Object
        Dim objRegex As Object
        Dim objRegMC As Object
        Dim strResponse As String
        Dim strSite As String

        Set objXmlHTTP = CreateObject("MSXML2.XMLHTTP")
        strSite = "http://msdn.microsoft.com/en-us/goglobal/bb964664"

        On Error GoTo ErrHandler
        With objXmlHTTP
            .Open "GET", strSite, False
            .Send
            If .Status = 200 Then strResponse = .ResponseText
        End With
        On Error GoTo 0

        strResponse = Replace(strResponse, "</td><td>", vbNullString)
        Set objRegex = CreateObject("vbscript.regexp")
        With objRegex
            .Pattern = "><td>([a-zA-Z- ]+)[A-Fa-f0-9]{4}" & lngCode
            If .Test(strResponse) Then
                Set objRegMC = .Execute(strResponse)
                GetTxt = objRegMC(0).submatches(0)
            Else
                GetTxt = "Value not found from " & strSite
            End If
        End With
        Set objRegex = Nothing
        Set objXmlHTTP = Nothing
        Exit Function
ErrHandler:
        If Not objXmlHTTP Is Nothing Then Set objXmlHTTP = Nothing
        GetTxt = strSite & " unable to be accessed"
    End Function
 
Upvote 0

Forum statistics

Threads
1,215,873
Messages
6,127,442
Members
449,382
Latest member
DonnaRisso

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top