Microsoft KB Archive/215382

= BUG: "Type Mismatch" Error When You Call an eVC DLL That Returns Variants =

Article ID: 215382

Article Last Modified on 9/4/2002

-

APPLIES TO


 * Microsoft eMbedded Visual Basic 3.0

-



This article was previously published under Q215382



SYMPTOMS
When you try to call an eMbedded Visual C++ (eVC) dynamic-link library (DLL) that returns a variant, you receive a "Type Mismatch" error.



CAUSE
Microsoft Visual Basic expects return values from functions to be passed by value. However, there is no device-independent way to pass large structures, such as variants, by value.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Build the eVC Component
 Start eMbedded Visual C++. From the File menu, click New. On the Projects tab, click WCE Dynamic-Link Library. In the Project name text box, type a project name (such as ReturnVariant ). In the CPUs list box, click the appropriate platform for your Microsoft Windows CE device, and then click OK. In the WCE Dynamic-Link Library dialog box, click An empty Windows CE DLL project, and then click Finish.</li> Click OK to create the project.</li> From the File menu, click New.</li> On the Files tab, click C++ Source File.</li> In the File name text box, type a file name (such as ReturnVariant.cpp ), and then click OK.</li> From the File menu, click New.</li> On the Files tab, click Text File.</li> In the File name text box, type a file name (such as ReturnVariant.def ), and then click OK.</li>  From the Windows menu, open the ReturnVariant.cpp file, and paste the following code:
 * 1) include<windows.h>;

VARIANTARG __stdcall ReturnVar(VARIANTARG &v1) {  return v1; }                   </li>  Open the ReturnVariant.def file, and paste the following code: EXPORTS ReturnVar </li> From the WCE Configuration toolbar, select the appropriate device and build information.</li> Ensure that the Windows CE device is connected to the desktop development computer.</li> From the Build menu, click Rebuild All. The DLL is compiled and downloaded to the device.</li> From the File menu, click Save Workspace, and then click Exit.</li></ol>

Build the eVB Component
<ol> Start a new Windows CE project in eMbedded Visual Basic based on your target device platform.</li> Add a CommandButton control to Form1.</li> <li> Paste the following code into Form1: Option Explicit Public Declare Function ReturnVar Lib "ReturnVariant" _ (ByRef v1 As Variant) As Variant

Private Sub Command1_Click Dim x As Variant Dim y As Variant x = ReturnVar(y) End Sub </li> <li>Ensure that the device is connected to the desktop development computer and that you are running the project on the default device.</li> <li>Run the project.</li> <li>On the device, click Command1. The "Type Mismatch" error occurs.</li></ol>

Additional query words: wce vbce evb evc variant

Keywords: kbbug kbnofix kbapi kbtoolkit KB215382

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.