FIX: Visual Basic 6.0 Booleans are Coerced to Localized Strings (216379)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q216379 SYMPTOMS
When Boolean constants or variables are concatenated into a string and the Regional Setting is not English, Visual Basic 6.0 coerces the Boolean value to a string containing the text of the value. For example, when the Regional Settings are set to French, you would see the string "Vrai" for True. Unfortunately, "Vrai" will not be converted back to the Boolean True even when CBool is applied. If CBool is applied to the string containing the localized word, a Type Mismatch error occurs.
RESOLUTION
The simplest work around is to apply CStr or Str$ to the Boolean constant or variable before it is coerced into the localized word. For example, in the following sample, the Boolean value True is explicitly converted to a string to retain the English value. The string can then be successfully parsed and converted back to a Boolean value.
sTemp = "-" & CStr(True) ' CStr keeps the English word True.
Debug.Print sTemp
sTemp = Right(sTemp, 4)
Debug.Print sTemp
bTemp = CBool(sTemp) ' No Type Mismatch error.
Modification Type: | Major | Last Reviewed: | 5/13/2003 |
---|
Keywords: | kbBug kbfix kbIntl kbIntlDev kbVS600sp3fix KB216379 |
---|
|