jmerritt
asked on
Masked Edit Box
Hi.
Does anybody know why the MaskEdBox control in VB 6 SP 5 doesn't seem to be locale aware? I have it
in my app with the format property = $##,0.00;($#,##0.00). I also use code to set formats such as
label1.caption = formatcurrency(rate.text)
The code works fine - when I change my regional settings and reboot the machine the label reflects the
local currency, date/time, etc formats. However, the maskedbox control always gives the "$" symbol
rather than the regional currency symbol. Does anybody know if this is a known issue and/or if there
is a workaround?
Worst case I suppose I could pull the maskedbox controls out and format the textboxes through code.
Seems strange the folks in Redmond would miss this one...
Does anybody know why the MaskEdBox control in VB 6 SP 5 doesn't seem to be locale aware? I have it
in my app with the format property = $##,0.00;($#,##0.00). I also use code to set formats such as
label1.caption = formatcurrency(rate.text)
The code works fine - when I change my regional settings and reboot the machine the label reflects the
local currency, date/time, etc formats. However, the maskedbox control always gives the "$" symbol
rather than the regional currency symbol. Does anybody know if this is a known issue and/or if there
is a workaround?
Worst case I suppose I could pull the maskedbox controls out and format the textboxes through code.
Seems strange the folks in Redmond would miss this one...
Hi,
Have you checked your Autoexec.bat or Config.sys files as these values can also be ste there any may overide your regional settings ?
Cheers,
T.
Have you checked your Autoexec.bat or Config.sys files as these values can also be ste there any may overide your regional settings ?
Cheers,
T.
Hi jmerritt,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Refund points and save as a 0-pt PAQ.
*** deighton's code is good, but not on point.
jmerritt, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit. Explain why.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Refund points and save as a 0-pt PAQ.
*** deighton's code is good, but not on point.
jmerritt, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit. Explain why.
==========
DanRollins -- EE database cleanup volunteer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
MaskEdBox1.Mask = getmask
End Sub
'in a bas module
Option Explicit
Public Type CURRENCYFMT
NumDigits As Long
LeadingZero As Long
Grouping As Long
lpDecimalSep As String
lpThousandSep As String
NegativeOrder As Long
PositiveOrder As Long
lpCurrencySymbol As String
End Type
Public Declare Function GetCurrencyFormat Lib "kernel32.dll" Alias "GetCurrencyFormatA" _
(ByVal Locale As Long, ByVal dwFlags As Long, ByVal lpValue As String, lpFormat _
As Any, ByVal lpCurrencyStr As String, ByVal cchCurrency As Long) As Long
Const LOCALE_USER_DEFAULT = &H800
Const LOCALE_SYSTEM_DEFAULT = &H400
Function getmask() As String
Dim cft As CURRENCYFMT ' custom formatting settings
Dim formatted As String ' receives the formatted number strings
Dim strlen As Long ' the length of the formatted string
Dim c As Long
' Display the value formatted according to the current locale.
formatted = Space(256)
strlen = GetCurrencyFormat(LOCALE_S
formatted, Len(formatted))
formatted = Left(formatted, strlen)
For c = 1 To Len(formatted)
getmask = getmask & IIf(IsNumeric(Mid(formatte
Next
Debug.Print "User locale format: "; formatted
End Function