locked
How to get UICulture in VB? RRS feed

  • Question

  • User-130510759 posted

    Hi,

    Can somebody please point me in the right direction to get a user's regional settings? I need to show dates and currency based on the user's region not the server's.

    I understand I should use UICulture but I'm having a hard time finding an example of how to do retrieve this in vb? 

    Any help is greatly appreciated.

    Thanks!

    Friday, November 23, 2018 7:50 PM

Answers

All replies

  • User-1716253493 posted

    https://weblog.west-wind.com/posts/2014/Mar/27/Auto-Selecting-Cultures-for-Localization-in-ASPNET

    Users can set the UI culture and culture in their browsers. For example, in Microsoft Internet Explorer, on the Tools menu, users can click Internet Options, on the General tab, click Language, and then set their language preference. If the enableClientBasedCultureattribute of the globalization element in the Web.config file is set to true, ASP.NET can set the UI culture and culture for a Web page automatically, based on the values that are sent by a browser.

    https://msdn.microsoft.com/en-us/library/bz9tc508.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-3

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 23, 2018 10:05 PM
  • User-130510759 posted

    Great, thanks a ton.

    If the enableClientBasedCultureattribute of the globalization element in the Web.config file is set to true, ASP.NET can set the UI culture and culture for a Web page automatically, based on the values that are sent by a browser.

    That's the missing piece I've been looking for... =)

    Friday, November 23, 2018 10:09 PM
  • User1120430333 posted

    I understand I should use UICulture but I'm having a hard time finding an example of how to do retrieve this in vb? 

    You probably are not going to find a VB example, since VB.NET is proprietary to MS and not an ISO and ECMA standard like C# is that has plenty of C# examples out on the Internet

    You may have to use an online C# to VB converter for a C# example you see. It may or many not work for you.

    You post the link or post the code for C# example in hopes that someone in the forum will convert the code for you.  

    In today's it helps if you know both languages.

    Friday, November 23, 2018 10:26 PM
  • User-1716253493 posted

    Try this

    Dim uc As String = UICulture

    Saturday, November 24, 2018 12:06 AM
  • User-130510759 posted

    You probably are not going to find a VB example, since VB.NET is proprietary to MS and not an ISO and ECMA standard like C# is that has plenty of C# examples out on the Internet

    ....

    In today's it helps if you know both languages.

    Thanks.

    Yes... this true. Although MS say they still support VB its obvious the preference is C#. VB examples for .NET are not as readily available.

    Sunday, November 25, 2018 4:35 PM
  • User-130510759 posted

    Thanks for this... I was able to convert the code and get up and running for the most part. If I pass a culture to the sub it works fine, however I can't seem to get it to auto detect the culture from the browser. It is just defaulting to en-US which is the machine default. I'll look at it again and see if I can get it working.

    Sunday, November 25, 2018 4:42 PM