How can I get the List Separator under Visual Basic .NET 2003?

Posted on 2008-11-14
Last Modified: 2012-05-05

I would like to ask if you could advice how can I get the List Separator from Locale in VB 2003.
If I used the solution of VB 6 (GetLocalInfo()) it was not working.

Could you tell me what i did wrong?

Thank you so much
best regards
Public Declare Function GetLocaleInfo Lib "kernel32" Alias _

      "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, _

           ByVal cchData As Long) As Long

Public Const LOCALE_SLIST = &HC

Dim ListSeparator As String

GetLocaleInfo(Locale, LOCALE_SLIST, ListSeparator, 0)

Open in new window

Question by:eesdil
    LVL 44

    Expert Comment

    Hello eesdil,

    Dim ListSeparator As String = System.Globalization.TextInfo.ListSeparator()



    Author Comment

    Hi Tim,

    Thank you for the quick answer.
    but I have some issues with it :)
    Do I have to declare something for it?

    I have tried usage from msdn, but it didnt work either...
    It is throwing an excepten: Object reference not set to an instance of an object

    Could you help what it is?
    thanks in advance


    Dim infoInstance As TextInfo
    Dim listSep As String
    listSep = infoInstance.ListSeparator

    Open in new window

    LVL 44

    Accepted Solution


    As always it is never quite as easy as it should be:

            Dim instance As Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture

    Open in new window


    Author Comment

    Hi Tim,

    thanks a lot it is working perfectly (out of box)

    best regards,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now