[vb] GetNumberFormat API

Pagina: 1
Acties:

  • Pc123
  • Registratie: Oktober 2000
  • Laatst online: 15-09 20:53
Ik wil met de GetNumberFormat API zorgen dat m'n progje aan de locale van de gebruiker wordt aangepast, maar t lukt niet.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Option Explicit
Private Declare Function GetNumberFormat Lib "kernel32.dll" Alias "GetNumberFormatA" _
    (ByVal Locale As Long, ByVal dwFlags As Long, ByVal lpValue As String, lpFormat _
    As Any, ByVal lpNumberStr As String, ByVal cchNumber As Long) As Long
Private Const LOCALE_USER_DEFAULT = &H800
Private Sub Form_Load()

Dim formatted As String  ' receives the formatted number strings
Dim strlen As Long   ' the length of the formatted string

formatted = Space(256)
strlen = GetNumberFormat(LOCALE_USER_DEFAULT, 0, "-1234567.89", ByVal CLng(0), formatted, Len(formatted))
formatted = Left(formatted, strlen)
Debug.Print "User locale format: "; formatted

End Sub

Dit geeft: User locale format: -1,234,567.89

Terwijl m'n locale toch echt op Nederlands staat en ik een "," als decimaal symbool gebruik (zo staat het ook in Control Panel). -1.234.567,89 zou het dus moeten zijn.

Heeft iemand enig idee wat het probleem kan zijn??

  • Crazy D
  • Registratie: Augustus 2000
  • Laatst online: 17-09 08:12

Crazy D

I think we should take a look.

Hmm nee niet zo gauw, maarre als je Format$(123456.78, "0,000.000") doet, wat krijg je dan?
Ik gebruik nl nog weleens simpel de format functie, even kijken of een format van 1.2 een . of een , oplevert :)

Exact expert nodig?


  • Pc123
  • Registratie: Oktober 2000
  • Laatst online: 15-09 20:53
Voor getallen kan dat ook inderdaad, mooi :)

Voor andere dingen zal ik toch iets anders moeten gebruiken.

Ik heb al een work-around:
In HKCU\Control Panel\International staat een heleboel, is wel minder netjes, maar t werkt wel.