Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 12

Creating the Interface Class

An Interface class is just an empty class template containing procedures to implement class methods and properties as discussed in the subsections immediately following "Implementing COM Components Through Class Modules" in this chapter. You don't normally put any code or Private variable declarations in an Interface class, only the blank procedures.

Therefore, the entire contents of an IVehicle Interface class might look like Listing 12.17.

LISTING 12.17
THIS IS ALL THE CODE REQUIRED TO SET UP THE IVEHICLE INTERFACE CLASS

Option Explicit

Public Property Let Color(newval As Long)
End Property
Public Property Get Color() As Long
End Property

Public Property Get MaxSpeed() As Single
End Property
Public Property Let MaxSpeed(newval As Single)
End Property

Public Function Travel(xStart, yStart, xEnd, yEnd) As Single
End Function

Notice that the IVehicle Interface provides two properties (Color and MaxSpeed) and one method (Travel).

You specify the type of each property and the number and type of the parameters that the method receives as well as its return value. You specify absolutely no behavior beyond this, however. The way that these members will function depends completely on the programmer who uses this Interface in other classes.


  

<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved