Try It Out - Using the OLE/COM Viewer
Let's try to illustrate the presence of interfaces by using the OLE/COM Viewer utility that comes with Visual C++ to inspect our recently built ActiveX objects. If you don't have Visual C++ or the Visual C++ tools installed on your machine, you can download the tool from http://www.microsoft.com/com/resources/oleview.asp. If you can't get hold of it, don't worry. This is the best tool to illustrate the interfaces on our object, but you should be able to follow the discussion through the screenshots.
1. Run the OLE/COM Viewer. Expand Object Classes then expand All Objects.
2. Scroll down until you find WroxCommerce.Visit. (You may have to scroll down quite a long way.) Expand the object. This is what our WroxCommerce.Visit object looks like inside this utility:

Look at the list of interfaces shown in the screenshot. The highlighted Visit interface shows the existence of the interface VB builds that just features the methods and properties on our object.
Note, although this is called Visit, it is an interface, not a class.
3. Let's look now at what's inside the Visit interface. To do this, double-click on the Visit object. This will display a little dialog with a button labeled View Type Info. Click this button and you'll see something like this:

4. Lastly, close down the ITypeInfo Viewer and then close down OLE/COM Viewer as well, otherwise we’ll prevent later examples from working.
When we examine the interface, we can see that this object contains only the methods we created on it. Note also that VB has defined these methods as having the parameters we defined against them. COM uses the term BSTR to represent the As String directive that you're familiar with. Notice that the Class_Terminate method has not made it into this interface. As you've probably guessed, that's because it's a private method and is therefore not accessible from outside the object.
This discussion is leading up to how we build another interface on our VB objects that lets us create public methods accessible to other objects in the model, but prevents those methods from being accessible to ASP.
Creating our own Interface
To achieve our aim of creating public methods for access by other objects, but not by ASP, we're going to create an interface definition of our own and then tell the Visit object that it supports that alternative interface. We can then pass that alternative interface through to other objects in the model when they're created.
Try It Out - Creating an Interface in the WroxCommerce Project
5. To kick off, return to the VB Project, add a new class module, and call it IUtility. We use the "I" to signify that it's an interface, in accordance with the COM standards.
6. When you create interface definitions, you simply define the methods and properties. You do not under any circumstances enter code into the methods and properties that are defined in the interface class module. So, it's OK to use the Public Property and Public Function constructs, but no methods or properties can contain any code. The next task is to enter the following:
' DB - property to return a populated and configured database object...
Public Property Get DB() As Database
End Property
' Visit - property to return the Visit object back again...
Public Property Get Visit() As Visit
End Property
To clarify the earlier point about where you can and can't put code, the above code is fine; however, the following two segments of code are both not acceptable:
' DB - property to return a populated and configured database object...
Public Property Get DB() As Database
MsgBox "There's code here. There shouldn't be!"
End Property
Dim Buf As String
Buf = "There's code here. There shouldn't be!"
' DB - property to return a populated and configured database object...
Public Property Get DB() As Database
End Property
Literally, the only things that can be in an interface class module are lines that are blank lines, lines that are comments, lines that start Public Property or Public Function, and lines that start End Property or End Function.
7. Our next job is to tell the Visit object that it implements (in other words - supports) that interface. So make the following addition to the Visit class module:
' this variable holds the connection string needed to
' connect to the database...
Private m_strDBString as String
' tell it what interfaces it supports...
Implements IUtility
When we tell an object that it implements an interface we enter into a contract with VB that we will add functions in order for the object to handle each of the methods and properties in the interface.
8. In the object drop-down list box in the top left of the code window, you should now be able to find the IUtility interface. Selecting that will display a list of the methods and properties on the interface, as shown here:

Continued...