BUG: CDK: VBSetVariantValue Return Value Changed in 4.0Last reviewed: February 22, 1996Article ID: Q142465 |
The information in this article applies to:
SYMPTOMSThe return value of the VBSetVariantValue function in the VBAPI library has changed in the 16-bit version of Microsoft Visual Basic version 4.0. This change in behavior affects 16-bit DLLs and custom controls (VBXs) that previously worked with Microsoft Visual Basic version 3.0.
MORE INFORMATIONThe documentation for the VBSetVariantValue function in the Control Development Guide in the Professional Edition of Microsoft Visual Basic states that when this function is used with the documented VB_<type> types, a -1 value is returned for errors, and 0 is returned for success. This statement is no longer true for DLLs and custom controls (VBXs) used with Visual Basic 4.0. The VBSetVariantValue function returns -1 for errors, 0 or greater for success.
STATUSMicrosoft has confirmed this to be a issue in the 16-bit version of Visual Basic for Windows version 4.0. We are researching this issue and will post new information here in the Microsoft Knowledge Base as it becomes available.
WORKAROUNDTo indicate success, change the DLL or VBX source code to handle return values of 0 or greater, instead of equivalence to 0. For example, if you have code that resembles the following:
#include <vbapi.h> #define SUCCESS 0 #define FAIL -1 int VBAPI SetMyVariant (LPVAR pVariant) { short NewValue = 0x1234; ERR nResult; nResult = VBSetVariantValue (pVariant, VT_I2, (LPVOID) &NewValue); if (0 == nResult) return SUCCESS; else return FAIL; }A DLL or VBX that contains this function correctly returns SUCCESS when used from a Visual Basic version 3.0 program. When the same DLL or VBX is used from a Visual Basic version 4.0 program, it incorrectly returns FAIL. You can avoid this problem by changing the line:
if (0 == nResult)to
if (0 <= nResult) -OR-you can test for a failure only. For example:
if (-1 == nResult) return FAIL; else return SUCCESS; |
Additional reference words: 4.00 vb4win vb416 buglist4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |