2009-10-09

Using COM objects in VB.NET

I am an old-fashioned guy and right now even though I uses VB.NET for my new programming, I still need to resort to old COM objects sometimes.

I find there is not much references to facilitate the process (e.g. I do not like command line tools). If I have a VB6 project orginally, the Studio Express can import it automatically. But if I starts a new .NET project, I find the following procedures is the quickest:

(1) Add the COM reference in the "Tools" | "Choose Toolbox Items" menu, so that the object is selectable in the left Toolbox


(2) Choose the COM Components Tab. If your object has been registered before hand, it is listed. Otherwise, click the Browse button to include it in the list


(3) Then you will find the Componet will appear in the left Toolbox. You then can drag it into your form.


(4) You will find VB.NET will automatically add appropriate references in your Project Properties, as in the following screen dump. In my cases, VB.NET add two references: one is the Interop and one is the AxInterop