Microsoft KB Archive/184884

{|
 * width="100%"|

BUG: VarCyFromStr Error When Input String Contains '$'

 * }

Q184884

-

The information in this article applies to:


 * Microsoft Windows CE

-

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.

Steps to Reproduce Behavior
The following code demonstrates the problem:

  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"......................................"; VarCyFromStr( szInput, 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); Additional query words:

Keywords : kbOSWinCEsearch

Issue type : kbbug

Technology : kbWinCESearch