Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleGet internationalization information using GetLocaleInfo
Keywordsinternationalization, GetLocaleInfo
CategoriesSoftware Engineering
 
Function LocaleInfo uses the GetLocalInfo API function to get a particular piece of internationalization information.

Form_Load uses the GetUserDefaultLCID API function to get the computer's LCID. It then uses that value and the LocaleInfo function to get pieces of information. It passes the result to subroutine AddRow to display the information in a MSFlexGrid.

This example displays a BIG list of values describing country, language, days of the week, months, time, dates, numbers, money, and miscellaneous values.

 
' Return a piece of locale information.
Private Function LocaleInfo(ByVal locale As Long, ByVal _
    lc_type As Long) As String
Dim length As Long
Dim buf As String * 1024

    length = GetLocaleInfo(locale, lc_type, buf, Len(buf))
    LocaleInfo = Left$(buf, length - 1)
End Function

Private Sub Form_Load()
Dim locale_id As Long

    '...
    locale_id = GetUserDefaultLCID()
    
    ' Load the values.
    ' Country.
    AddRow "Country"
    AddRow "Abbreviated Country Name", _
        LocaleInfo(locale_id, LOCALE_SABBREVCTRYNAME)
    AddRow "Native Name of Country", LocaleInfo(locale_id, _
        LOCALE_SNATIVECTRYNAME)
    '...
End Sub

' Add a row to the FlexGrid. If the second parameter
' is missing, color the row as a header.
Private Sub AddRow(ByVal item_name As String, Optional _
    ByVal item_value As Variant)
    MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
    MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 0) = _
        item_name
    If IsMissing(item_value) Then
        MSFlexGrid1.Row = MSFlexGrid1.Rows - 1
        MSFlexGrid1.Col = 0
        MSFlexGrid1.CellBackColor = _
            MSFlexGrid1.BackColorFixed
        MSFlexGrid1.Col = 1
        MSFlexGrid1.CellBackColor = _
            MSFlexGrid1.BackColorFixed
    Else
        MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 1) = _
            item_value
    End If
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated