KEMBAR78
Visual Basic –User Interface- V | PPTX
SHARBANI BHATTACHARYA
Visual Basic –User Interface-V
Govt. Polytechnic(W)
Faridabad
29th September 2016
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.
It 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
try
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
Code needs to throw an
exception using the throw
keyword.
FINALLY BLOCK
Code 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
THANK YOU

Visual Basic –User Interface- V

  • 1.
    SHARBANI BHATTACHARYA Visual Basic–User Interface-V Govt. Polytechnic(W) Faridabad 29th September 2016
  • 2.
    INTERFACES Interfaces are declaredwith the following structure  Public Interface <Name of the interface>  :  <decleration of memebrs of the interface, means methods and properties  structure>  :  End Interface
  • 3.
    Interface IShape Sub Draw(ByValcoord() As ArrayList) End Interface interface IShape{ void Draw(ArrayList coord); }
  • 4.
    HOW USE INPROGRAMMING Interfaces are implemented using Implements keyword. All the members of the interface are implemented with Implements keyword.
  • 5.
    ABSTRACT CLASS VSINTERFACE 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.
  • 6.
    WHEN TO USEINTERFACES The situation at which we need to implement the functionalities of two or more objects into one derived object. It makes the derived object to refer to the interface methods and properties for syntax verification.
  • 7.
    EVENTS Events are situationsat 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.
  • 8.
    EXAMPLE The class designercan 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.
  • 9.
    HOW EVENTS AREHANDLED 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.
  • 10.
  • 11.
    STRUCTURE Structures are usedto create a variable set of different datatypes in VB.NET.
  • 12.
    FEATURES OF OOPS Implementinginterfaces Constructors, methods, properties, fields, constants and events •Shared constructors
  • 13.
    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
  • 14.
  • 22.
    ERROR AND EXCEPTIONHANDLING 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.
  • 23.
     Error andexception 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
  • 24.
     The .NETFramework Class Library (FCL) and Common Language  Runtime (CLR) provide a rich infrastructure to catch and handle exceptions. ERROR AND EXCEPTION HANDLING
  • 25.
  • 26.
    TRY BLOCK Enclose ablock of code that has the potential of throwing exceptions within a try block.
  • 27.
    CATCH BLOCK  Acatch 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.
  • 28.
    THROW BLOCK Code needsto throw an exception using the throw keyword.
  • 29.
    FINALLY BLOCK Code withinthe finally block is guaranteed to always execute and usually contains cleanup code.
  • 33.
    EXAMPLE OF EXCEPTIONS System.IO.IOException  System.DivideByZeroException  System.ArithmeticException  System.FormatException
  • 60.
    REFERENCES  dotNET Tutorialfor Beginners, India Community Initiative  Microsoft Visual Studio 2010 by Michael Halvorson, Microsoft  Microsoft Visual Basic 6.0 by Francesco Balena ,Microsoft Press
  • 61.