INTERFACES Interfaces are declared with the following structure Public Interface <Name of the interface> : < decleration of memebrs of the interface, means methods and properties structure> : End Interface
Interface IShape Sub Draw( ByVal coord () As ArrayList ) End Interface interface IShape { void Draw( ArrayList coord ); }
How use in Programming Interfaces are implemented using Implements keyword. All the members of the interface are implemented with Implements keyword.
Abstract Class Vs Interface Abstract Class Interface Only one Abstract class can be inherited into the derived class. Interfaces enable multiple inheritance to the object. Members of the abstract class can or cannot have implementation. Interfaces contains only the definitions for the members without implementation.
wHen to use Interfaces The situation at which we need to implement the functionalities of two or more objects into one derived object . I t makes the derived object to refer to the interface methods and properties for syntax verification.
Events Events are situations at which the message is sent to an object to signal the occurrence of the action . These actions can be caused by the user interaction or within the object itself.
Example The class designer can create an event and raise the same through its methods and properties. These events will be captured by the object user and perform his/her required operation.
How EVENTS are Handled The users create an instance of he Button class Select the onclick event related to the button object Write an action to be performed on click of the button.
Events Usage
STRUCTURE Structures are used to create a variable set of different datatypes in VB.NET.
features of OOPS Implementing interfaces Constructors , methods, properties, fields, constants and events •Shared constructors
STRUCTURE IN VB .NET Structure Person Public FirstName As String Public LastName As String Public Address As String Public Pincode As String Public DateOFBirth As DateTime Public Sub DisplayInfo () Dim msg As String msg = FirstName & " " & LastName & vbCrLf msg = msg & Address & vbCrLf msg = msg & "PIN – " & Pincode msg = msg & "Date of Birth : " & DateOFBirth.ToString End Sub End Structure
EVENTS
Error and Exception Handling An Exception is an abnormal/exceptional/unexpected condition that disrupts the normal execution of an application. A distinction needs to be made between expected conditions and unexpected conditions.
Error and exception handling are a part and parcel of every good language, framework class library, or application and should form a part of your applications too right from the planning stages. Error and Exception Handling
The .NET Framework Class Library (FCL) and Common Language Runtime (CLR) provide a rich infrastructure to catch and handle exceptions. Error and Exception Handling
t ry throw catch finally Structure of Exception Handling
Try BLOCK Enclose a block of code that has the potential of throwing exceptions within a try block.
CATCH BLOCK A catch handler associated with the exception that is thrown catches the exception. There can be one or more catch handlers and each catch handler can be associated with a specific exception type that it can handle. The catch blocks are generally used to gracefully inform the user of the error and to possibly log the error to a log file or to the system event log.
tHrOW BLOCK C ode needs to throw an exception using the throw keyword.
FINALLY BLOCK C ode within the finally block is guaranteed to always execute and usually contains cleanup code.
Example of Exceptions System.IO.IOException System.DivideByZeroException System.ArithmeticException System.FormatException
REFERENCES dotNET Tutorial for Beginners, India Community Initiative Microsoft Visual Studio 2010 by Michael Halvorson, Microsoft Microsoft Visual Basic 6.0 by Francesco Balena ,Microsoft Press