Differences in Visual Basic and C++ Calling Conventions
Visual Basic (VB) does several things for the user of COM components. First, for object property calls, the "get_" and "put_" are dropped off the C++ raw interface names. The result is that the object property has the one name, and its use determines whether it is being set or retrieved. And second, as shown in the body of this API document, all COM calls return an HRESULT. However for VB, the call returns the [out, retval] parameter when the HRESULT is S_OK., that is, when no error has occurred. If the underlying call had a problem, such that some COM error needs to be returned, VB sets up an Err object based on the HRESULT and then "throws" the Err object. The user is expected to use "ON ERROR" to catch any possible errors, and then take appropriate action.