BUG: VarCyFromStr() Error When Input String Contains '$' (184884)
The information in this article applies to:
This article was previously published under Q184884 SYMPTOMS
When VarCyFromStr() is passed a string containing a '$', it returns
incorrect or unpredictable results.
RESOLUTION
To work around the problem, simply remove the '$' from the input string by
pointing to the character beyond it or remove it and prepend it again after
the conversion. For example, you can modify the sample code in the MORE
INFORMATION section to point the input string past the '$':
CURRENCY cy;
LPWSTR szInput = L"$1,234,567.89";
MessageBox(hWnd, szInput, L"Currency Input String", MB_OK);
// Pad output string with "."
LPWSTR szOutput = L"......................................";
LPWSTR szNoDollarSign = wcsstr(szInput, '$');
szNoDollarSign = szNoDollarSign ? (szNoDollarSign + 1) : szInput;
VarCyFromStr( szNoDollarSign, LANG_USER_DEFAULT, 0, &cy );
unsigned long lFinal = (unsigned long)(cy.int64/100);
wsprintf( szOutput, TEXT( "%lu" ), lFinal );
MessageBox(hWnd, szOutput, L"Currency converted String", MB_OK);
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. We are researching this bug and will post
new information here in the Microsoft Knowledge Base as it becomes
available.
Modification Type: | Major | Last Reviewed: | 1/14/2000 |
---|
Keywords: | kbbug KB184884 |
---|
|