|
Expertise: Advanced
Language: Visual Basic
November 20, 2000
Passing an ActiveX Control As a Parameter
Trying to pass an ActiveX control as a parameter to a method on an external ActiveX DLL (or EXE), garners a Type Mismatch error. This error is peculiar, as it does not happen on a development computer. It occurs when the component is installed on another computer.
This problem has been recognized in the MSDN knowledge base under the article titled PRB: Passing ActiveX Control to Component Gives Type Mismatch Error Message. The solution proposed in the knowledge base article is to make the receiving variable type object so that it is assigned without throwing a Type Mismatch error. This solution does not let you sink the events of the ActiveX control in the ActiveX DLL to which the control is being passed. In order to use the WithEvents keyword, you need to declare your variable with the correct type of information, like Private WithEvents m_tree As TreeView. A solution to this problem is to refer to the ActiveX control in your DLL using References instead of Components.
To do this, clear the entry corresponding to the ActiveX control in the Project-Components dialog. Then open up Project-Reference dialog and select the same ActiveX control. Compile the DLL and install. This will eliminate the type mismatch error when the application is run.
Mahesh Hegade
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
|