[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Win NT/ Decimal separator

Posted on 1998-12-03
5
Medium Priority
?
416 Views
Last Modified: 2008-03-17
Currently for Win95, I use the WIN.INI file to get the decimal and thousands separator for my application. I've noticed, however, that the Win NT WIN.INI file does not hold this information. Is there a NT equivalent, or am I going to have to used API calls to get that info?
0
Comment
Question by:BergJC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Expert Comment

by:vikiing
ID: 1448041
If your idea is to format numeric output, you can use the standard mask "#,###.##" (or similar). With that, Format$() function will use whatever is defined in your system, this is, if your system is set to use a comma for decimal separator and period for thousands, that mask will do the job.

If comma and period swap their meaning, *THE SAME* mask will keep on working, giving always the right display.
0
 

Expert Comment

by:budgie_b
ID: 1448042
You must be careful because depending on which regional settings for the machine are set will change the dec sep required.  It is by far better to use the API call:

Private 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

0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 120 total points
ID: 1448043
Use  LOCALE_SDECIMAL


Public Const LOCALE_ILANGUAGE = &H1         '  language id
Public Const LOCALE_SLANGUAGE = &H2         '  localized name of language
Public Const LOCALE_SENGLANGUAGE = &H1001   '  English name of language
Public Const LOCALE_SABBREVLANGNAME = &H3   '  abbreviated language name
Public Const LOCALE_SNATIVELANGNAME = &H4   '  native name of language
Public Const LOCALE_ICOUNTRY = &H5          '  country code
Public Const LOCALE_SCOUNTRY = &H6          '  localized name of country
Public Const LOCALE_SENGCOUNTRY = &H1002    '  English name of country
Public Const LOCALE_SABBREVCTRYNAME = &H7   '  abbreviated country name
Public Const LOCALE_SNATIVECTRYNAME = &H8   '  native name of country
Public Const LOCALE_IDEFAULTLANGUAGE = &H9  '  default language id
Public Const LOCALE_IDEFAULTCOUNTRY = &HA   '  default country code
Public Const LOCALE_IDEFAULTCODEPAGE = &HB  '  default code page
Public Const LOCALE_SLIST = &HC             '  list item separator
Public Const LOCALE_IMEASURE = &HD          '  0 = metric, 1 = US
Public Const LOCALE_SDECIMAL = &HE          '  decimal separator
Public Const LOCALE_STHOUSAND = &HF         '  thousand separator
Public Const LOCALE_SGROUPING = &H10        '  digit grouping
Public Const LOCALE_IDIGITS = &H11          '  number of fractional digits
Public Const LOCALE_ILZERO = &H12           '  leading zeros for decimal
Public Const LOCALE_SNATIVEDIGITS = &H13    '  native ascii 0-9
Public Const LOCALE_SCURRENCY = &H14        '  local monetary symbol
Public Const LOCALE_SINTLSYMBOL = &H15      '  intl monetary symbol
Public Const LOCALE_SMONDECIMALSEP = &H16   '  monetary decimal separator
Public Const LOCALE_SMONTHOUSANDSEP = &H17  '  monetary thousand separator
Public Const LOCALE_SMONGROUPING = &H18     '  monetary grouping
Public Const LOCALE_ICURRDIGITS = &H19      '  # local monetary digits
Public Const LOCALE_IINTLCURRDIGITS = &H1A  '  # intl monetary digits
Public Const LOCALE_ICURRENCY = &H1B        '  positive currency mode
Public Const LOCALE_INEGCURR = &H1C         '  negative currency mode
Public Const LOCALE_SDATE = &H1D            '  date separator
Public Const LOCALE_STIME = &H1E            '  time separator
Public Const LOCALE_SSHORTDATE = &H1F       '  short date format string
Public Const LOCALE_SLONGDATE = &H20        '  long date format string
Public Const LOCALE_STIMEFORMAT = &H1003    '  time format string
Public Const LOCALE_IDATE = &H21            '  short date format ordering
Public Const LOCALE_ILDATE = &H22           '  long date format ordering
Public Const LOCALE_ITIME = &H23            '  time format specifier
Public Const LOCALE_ICENTURY = &H24         '  century format specifier
Public Const LOCALE_ITLZERO = &H25          '  leading zeros in time field
Public Const LOCALE_IDAYLZERO = &H26        '  leading zeros in day field
Public Const LOCALE_IMONLZERO = &H27        '  leading zeros in month field
Public Const LOCALE_S1159 = &H28            '  AM designator
Public Const LOCALE_S2359 = &H29            '  PM designator
Public Const LOCALE_SDAYNAME1 = &H2A        '  long name for Monday
Public Const LOCALE_SDAYNAME2 = &H2B        '  long name for Tuesday
Public Const LOCALE_SDAYNAME3 = &H2C        '  long name for Wednesday
Public Const LOCALE_SDAYNAME4 = &H2D        '  long name for Thursday
Public Const LOCALE_SDAYNAME5 = &H2E        '  long name for Friday
Public Const LOCALE_SDAYNAME6 = &H2F        '  long name for Saturday
Public Const LOCALE_SDAYNAME7 = &H30        '  long name for Sunday
Public Const LOCALE_SABBREVDAYNAME1 = &H31  '  abbreviated name for Monday
Public Const LOCALE_SABBREVDAYNAME2 = &H32  '  abbreviated name for Tuesday
Public Const LOCALE_SABBREVDAYNAME3 = &H33  '  abbreviated name for Wednesday
Public Const LOCALE_SABBREVDAYNAME4 = &H34  '  abbreviated name for Thursday
Public Const LOCALE_SABBREVDAYNAME5 = &H35  '  abbreviated name for Friday
Public Const LOCALE_SABBREVDAYNAME6 = &H36  '  abbreviated name for Saturday
Public Const LOCALE_SABBREVDAYNAME7 = &H37  '  abbreviated name for Sunday
Public Const LOCALE_SMONTHNAME1 = &H38      '  long name for January
Public Const LOCALE_SMONTHNAME2 = &H39      '  long name for February
Public Const LOCALE_SMONTHNAME3 = &H3A      '  long name for March
Public Const LOCALE_SMONTHNAME4 = &H3B      '  long name for April
Public Const LOCALE_SMONTHNAME5 = &H3C      '  long name for May
Public Const LOCALE_SMONTHNAME6 = &H3D      '  long name for June
Public Const LOCALE_SMONTHNAME7 = &H3E      '  long name for July
Public Const LOCALE_SMONTHNAME8 = &H3F      '  long name for August
Public Const LOCALE_SMONTHNAME9 = &H40      '  long name for September
Public Const LOCALE_SMONTHNAME10 = &H41     '  long name for October
Public Const LOCALE_SMONTHNAME11 = &H42     '  long name for November
Public Const LOCALE_SMONTHNAME12 = &H43     '  long name for December
Public Const LOCALE_SABBREVMONTHNAME1 = &H44 '  abbreviated name for January
Public Const LOCALE_SABBREVMONTHNAME2 = &H45 '  abbreviated name for February
Public Const LOCALE_SABBREVMONTHNAME3 = &H46 '  abbreviated name for March
Public Const LOCALE_SABBREVMONTHNAME4 = &H47 '  abbreviated name for April
Public Const LOCALE_SABBREVMONTHNAME5 = &H48 '  abbreviated name for May
Public Const LOCALE_SABBREVMONTHNAME6 = &H49 '  abbreviated name for June
Public Const LOCALE_SABBREVMONTHNAME7 = &H4A '  abbreviated name for July
Public Const LOCALE_SABBREVMONTHNAME8 = &H4B '  abbreviated name for August
Public Const LOCALE_SABBREVMONTHNAME9 = &H4C '  abbreviated name for September
Public Const LOCALE_SABBREVMONTHNAME10 = &H4D '  abbreviated name for October
Public Const LOCALE_SABBREVMONTHNAME11 = &H4E '  abbreviated name for November
Public Const LOCALE_SABBREVMONTHNAME12 = &H4F '  abbreviated name for December
Public Const LOCALE_SABBREVMONTHNAME13 = &H100F

Public Const LOCALE_SYSTEM_DEFAULT& = &H800
Public Const LOCALE_USER_DEFAULT& = &H400

Const cMAXLEN = 255

Private Declare Function apiGetLocaleInfo Lib "kernel32" _
    Alias "GetLocaleInfoA" (ByVal Locale As Long, _
    ByVal LCType As Long, ByVal lpLCData As String, _
    ByVal cchData As Long) As Long


Function fLocaleInfo(lngLCType As Long) As String
Dim lngLocale As Long
Dim strLCData As String, lngData As Long
Dim lngX As Long

    strLCData = String$(cMAXLEN, 0)
    lngData = cMAXLEN - 1
    lngX = apiGetLocaleInfo(LOCALE_USER_DEFAULT, lngLCType, _
                    strLCData, lngData)
    If lngX <> 0 Then
        fLocaleInfo = Left$(strLCData, lngX - 1)
    End If
End Function
GetLocaleInfo

The GetLocaleInfo function retrieves information about a locale.

int GetLocaleInfo(
  LCID Locale,      // locale identifier
  LCTYPE LCType,    // type of information
  LPTSTR lpLCData,  // address of buffer for information
  int cchData       // size of buffer
);
 


Parameters



Locale

Specifies the locale to retrieve information for. This parameter can be a locale identifier created by the MAKELCID macro, or one of the following predefined values:
LOCALE_SYSTEM_DEFAULTDefault system locale.LOCALE_USER_DEFAULTDefault user locale.


LCType

Specifies one of the LCTYPE constants to indicate the type of information to be retrieved.

All LCTYPE values are mutually exclusive, with the exception of LOCALE_NOUSEROVERRIDE. An application may use the binary-OR operator to combine LOCALE_NOUSEROVERRIDE with any other LCTYPE value. If passed such an LCType value, the function bypasses user overrides, and returns the system default value for the requested LCID.

lpLCData

Points to a buffer to receive the requested data.

cchData

Specifies the size, in bytes (ANSI version) or characters (Unicode version), of the lpLCData buffer. If cchData is zero, the function returns the number of bytes or characters required to hold the information, and the buffer pointed to by lpLCData is not used.



Return Values

If the function succeeds, the return value is the number of bytes (ANSI version) or characters (Unicode version) written to the destination buffer, or if the cchData parameter is zero, the number of bytes or characters required to hold the locale information.

If the function fails, the return value is zero. To get extended error information, call GetLastError. GetLastError may return one of the following error codes:

ERROR_INSUFFICIENT_BUFFER
ERROR_INVALID_FLAGS
ERROR_INVALID_PARAMETER

Remarks

The GetLocaleInfo function always retrieves information in text format. If the information is a numeric value, the function converts the number to text using decimal notation.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in winnls.h.
  Import Library: Use kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.
0
 
LVL 2

Author Comment

by:BergJC
ID: 1448044
I am aware of this API call to get the decimal separator. I've already written the code for regional settings, I just need the separators. I used the WIN.INI file because it was much simpler (and when you don't support the system, you want to make it as simple as possible for others). I'm guessing that from your answers that there isn't an equivalent to the entries inside the Win95 WIN.INI file for WinNT. Is this correct?
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1448045
Yes, that it correct. The win.ini is not used anymore. The registry is always the most up to date information.
BTW: I think that using GetLocaleInfo is as easy as reading the win.ini
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 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