Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XP Regional Options 1

Status
Not open for further replies.

Creepers

Programmer
Nov 11, 2002
116
US
Have some users in Germany where they set their Regional Options to Germany. This impacts numeric values. For instance .001 (US) = ,001 Germany. In short, Germany users , where we in the US use .
Is there an API call or some other functionality that I can use with VB to get a machines Regional Options setting?
 
Use GetLocaleInfo function which returns locale-specific settings.
___
[tt]
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
Const LOCALE_SDECIMAL = &HE
Private Sub Form_Load()
'get decimal sign
Dim S As String
S = Space$(10)
GetLocaleInfo 0, LOCALE_SDECIMAL, S, Len(S)
S = Left$(S, InStr(S, vbNullChar) - 1)
MsgBox "Decimal Sign = " & S
End Sub[/tt]
___

To retrieve other locale settings, see other LOCALE_* constants.
 
Try this;

Function dpChar$()

dpChar$ = Mid$(Format$(0.1, "fixed"), 2, 1)

End Function

'you may find this useful too!


Function Val#(ByVal txt$)

'Wraps VBA.Val
' should make the whole system able to handle decimal point chars other than "."
' VBA val only works on decimals when the decimal char is "."

Static normal As Boolean, init As Boolean, dp$
If Not init Then
dp$ = dpChar()
normal = (dp$ = ".")
init = True
End If

If normal Then
Val = VBA.Val(txt$)
Else
Val = VBA.Val(Replace(txt$, dp$, "."))
End If

'VB help recommends CDbl but..
'the following dos'nt work with strings that contain numbers and text
' like eg. "5.4 mp" because the error is tripped and 0 is returned
'On Error Resume Next
'Val = CDbl(txt$)

End Function

regards Hugh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top