search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsFAQs
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Operating SystemsArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

View Other VB 6.0 Posts   Ask New Question 
what is an interface in vb6.0
RAJAN CRP posted at Friday, November 21, 2008 10:37 PM
What is an interface in vb 6.0? How to create and implement it? I want an explanation with an example code and also the steps involved.

Thanx in Advance

 
Re :: Interface in VB 6.0
Sanjay Verma replied to RAJAN CRP at Saturday, November 22, 2008 12:04 AM
Inheritance for Visual Basic 6.0 Users

Inheritance allows you to create new classes from existing classes. Inheritance can simplify the design of the application by providing a relationship structure between the various classes. It also supports code reuse, because only the new or different class behavior must be coded.

Visual Basic 6.0

Visual Basic 6.0 supports interface inheritance, covered in more detail in Interface Changes for Visual Basic 6.0 Users.

Visual Basic 2008

Visual Basic 2008 supports interface inheritance with the Interface Statement (Visual Basic) and Implements Statement. For more information on interfaces, see Interfaces in Visual Basic.

When a new class is created through implementation inheritance, the new class automatically gains all the members and implementation of the base class. The existing class is called the "base class." The new class is the "derived class." Additional members can be added to the class. The behavior of the base class can be changed by writing code in the new class. This technique is called overriding.

You can create classes by inheriting from the classes you create, from classes in references you add to your project, or from objects in the .NET Framework. Many classes of the .NET Framework are related by inheritance. For example, the TextBox class inherits from the System.Windows.Forms..::.TextBoxBase class.

Visual Basic 6.0

Visual Basic 6.0 does not support implementation inheritance.

Visual Basic 2008

Inheritance is declared in Visual Basic 2008 by the Inherits statement. In this example, the derived class Oak inherits from a base class Tree.

Visual Basic
Public Class Oak
    Inherits Tree
    ' Add code here to extend or 
    ' modify the behavior of the Tree class.
End Class

Visual Basic 6.0

In interface inheritance in Visual Basic 6.0, any class can act as an interface base class. There is no syntax for preventing any class to act as an interface base class. Likewise, there is no syntax to demand that a class act only as an interface base class.

Visual Basic 2008

Along with implementation inheritance, Visual Basic 2008 defines two class modifiers, MustInherit and NotInheritable. These modifiers let the programmer control the inheritance relationships in an application.

The MustInherit modifier on a class declaration indicates a class that cannot be instantiated:

Visual Basic
Public MustInherit Class BaseClass
End Class

This means that BaseClass cannot appear after the New keyword. Only classes that inherit from BaseClass and that do not also have the MustInherit modifier can be instantiated. In object-oriented literature and in other object-oriented languages, a MustInherit class is called an abstract class. A class that is not a MustInherit class, one that can be instantiated, is called a concrete class.

A related concept is the sealed class, a class that cannot serve as a base class. The NotInheritable keyword on a class definition indicates this status:

Visual Basic
Public NotInheritable Class DerivedClass
End Class

A NotInheritable class marks the edge of an inheritance hierarchy.

For more information, see Inheritance in Visual Basic.

Classes acting as interfaces in Visual Basic 6.0 are upgraded to interfaces in Visual Basic 2008. Consider this example of a base class and derived class from Visual Basic 6.0:

' Contents of class BaseClass
Public Sub BaseMethod()
End Sub

' Contents of class DerivedClass
Implements BaseClass
Private Sub BaseClass_BaseMethod()
End Sub

The Upgrade Wizard produces this upgraded code:

Visual Basic
Option Strict Off
Option Explicit On
Interface _BaseClass
    Sub BaseMethod()
End Interface

Friend Class BaseClass
    Implements _BaseClass
    Public Sub BaseMethod() Implements _BaseClass.BaseMethod
    End Sub
End Class

Friend Class DerivedClass
    Implements _BaseClass
    Private Sub BaseClass_BaseMethod() Implements _BaseClass.BaseMethod
    End Sub
End Class

Using inheritance instead of interfaces, the upgraded code can be modified to:

Visual Basic
Friend Class BaseClass
    Public Sub BaseMethod()
        ' Add code here to define BaseMethod.
    End Sub
End Class

Friend Class DerivedClass
    Inherits BaseClass
End Class

This eliminates one level of indirection, _BaseClass. Also, it eliminates one method definition, BaseClass_BaseMethod, because the method is inherited from the base class and does not need to be coded again. If the programmer wanted a different behavior for the derived class, the BaseMethod can be overridden as shown:

Visual Basic
Friend Class BaseClass
    Public Overridable Sub BaseMethod()
        ' Add code here to define BaseMethod.
    End Sub
End Class

Friend Class DerivedClass
    Inherits BaseClass
    Public Overrides Sub BaseMethod()
        ' Add code here to define behavior for DerivedClass.
    End Sub
End Class

Some techniques to consider in upgraded interfaces include:

  • Replace Interface statements with Inherits statements.

  • Implement the base class as an interface, rather than as a class that implements an interface. For more information see Interface Changes for Visual Basic 6.0 Users.

  • Implement base classes as MustInherit classes.

  • Implement derived classes as NotInheritable.

Hope this helps.
 
  Interfaces in Visual Basic
Binny ch replied to RAJAN CRP at Saturday, November 22, 2008 12:57 AM
Visual Basic 6 does not support inheritance or classes in the object-oriented sense of the construct. VB6 does support COM interfaces.
Defintion:
http://msdn.microsoft.com/en-us/library/h9xt0sdd.aspx
Example:


Option Strict Off
Option Explicit On
Interface _BaseClass
Sub BaseMethod()
End Interface

Friend Class BaseClass
Implements _BaseClass
Public Sub BaseMethod() Implements _BaseClass.BaseMethod
End Sub
End Class

Friend Class DerivedClass
Implements _BaseClass
Private Sub BaseClass_BaseMethod() Implements _BaseClass.BaseMethod

End Sub
End Class


See this link:
http://msdn.microsoft.com/en-us/library/yet634fk.aspx


 
  read this link
C_A P replied to RAJAN CRP at Saturday, November 22, 2008 1:57 AM
http://msdn.microsoft.com/en-us/library/ms973861.aspx
http://codebetter.com/blogs/eric.wise/archive/2005/06/02/63971.aspx

tutorial
http://www.lubankit.org/InheritanceTutorial.htm
http://java.sun.com/docs/books/tutorial/java/concepts/interface.html
http://articles.techrepublic.com.com/5100-10878_11-5032721.html
 
About interface in vb 6.0
Suraj Gaonkar replied to RAJAN CRP at Saturday, August 29, 2009 1:59 AM
end of post