FEDT VB.NET
F R O N T E N D D E S I G N T O O L
U S I N G
V B . N E T
P R E S E N T A T I O N B Y :
A N K I T V E R M A
( I T D E P A R T M E N T )
A N K I T V E R M A A S S T . P R O F E S S O R
U N I T - 3
Interface
 User interacts with application using well-defined user
interface.
 Two types of interface:
 CUI (Character User Interface)
 Commands for user interaction
 Not much user friendly
 E.g. Console Application
 GUI (Graphical User Interface)
 No need to remember commands
 Very easy to use & user friendly
 E.g. Windows Application
28-11-2014 ANKIT VERMA 2
28-11-2014 ANKIT VERMA 3
WINDOWS FORMS
Windows Form
 Accept input from user & display information.
 Develop desktop based application.
 Provides full support of database connectivity & image
formats.
 System.Windows.Forms namespace support Form
Class.
 Title Bar, Menu Bar & Control Box are at top of form.
 Main area is called Client Area, surrounded by border.
 Form associated controls enriched with predefined
Properties, Methods & Events.
28-11-2014 ANKIT VERMA 4
Windows Form
 Properties
 Define characteristics of controls like color, size, border etc.
 Methods
 Methods are defined by the action that an object can perform.
 Events
 These are actions that can be recognized by the objects.
 Event occur when the user, OS or application interact with
objects of program.
 They control the appearance & behavior of a form either at
design time or run time.
28-11-2014 ANKIT VERMA 5
Windows Form: Properties & Methods
 Backcolor
 BackgroundImage
 FormBorderStyle
 None
 Fixed Single
 Sizeable
 Fixed Dialog
 Fixed 3D
 Fixed Tool Window
 Sizeable Tool Window
 MaximizeBox
28-11-2014 ANKIT VERMA 6
Windows Form: Properties & Methods
 MaximizeBox
 MinimizeBox
 Text
 WindowState
 StartPosition
 CenterParent
 Manual
 CenterScreen
 WindowDefaultBounds
 WindowDefaultLocation
28-11-2014 ANKIT VERMA 7
Windows Form: Properties & Methods
 Activate
 Close
 Show
 Refresh
 Hide
 Dispose
28-11-2014 ANKIT VERMA 8
Windows Form : Example
 Example 1:
28-11-2014 ANKIT VERMA 9
Windows Form : Example
 Example 2:
28-11-2014 ANKIT VERMA 10
Windows Form: Events
 Activated
 Deactivate
 Click
 Load
 Closing
 Closed
28-11-2014 ANKIT VERMA 11
MDI Forms
 Display multiple windows at same time.
 MDI form act as parent form or container for all other
forms, called MDI parent form.
 Contain Menu Bar, Tool Bar and Status Bar.
 E.g. Word
 By default, VB.NET support SDI application, where
only one window displayed at a time.
 E.g. Wordpad
 In MDI Application, child forms are displayed as
independent windows under parent MDI window.
28-11-2014 ANKIT VERMA 12
MDI Forms
 Create a form & set IsMDIContainer property true, it
will act as container.
 Attach the menus to MIDI parent form.
 Click event of menu item, write:
Form2.Show()
 Add one more Form to project.
 Write code on load of Second Form:
Me.MdiParent = Form1
 Run the code & click on menu item.
28-11-2014 ANKIT VERMA 13
MDI Forms
28-11-2014 ANKIT VERMA 14
28-11-2014 ANKIT VERMA 15
CONTROLS
Controls
 Major controls are:
 Label
 Linklabel
 Textbox
 Button
 Checkbox
 Listbox
 Radiobutton
 Combobox
 Groupbox
 Hscrollbar
28-11-2014 ANKIT VERMA 16
 Vscrollbar
 Picturebox
 Timer
 ListView
 TreeView
 Panel
 ToolBar
 StatusBar
Controls : Properties & Methods
 Properties & Methods of controls are:
 Backcolor
 Forecolor
 Size
 Enable
 Locked
 Visible
 Location
 Font
 Maximum Size
 Minimum Size
28-11-2014 ANKIT VERMA 17
 Hide
 Show
 Select
 Refresh
28-11-2014 ANKIT VERMA 18
Label
Label
 Graphic control used to display text.
 User can’t edit text directly.
 Text properties can be set at Run Time / Design Time.
 It is in System.Windows.Form.Label class.
 Label can’t receive focus.
 Label Properties are:
 AutoSize
 BorderStyle
 Enabled
 Text Align
 Text
28-11-2014 ANKIT VERMA 19
Label : Example
 Example:
28-11-2014 ANKIT VERMA 20
28-11-2014 ANKIT VERMA 21
Textbox
Textbox
 Accept input from user & retrieve data from database.
 Textbox can be Multiline, Editable or ReadOnly.
 It is subclass of System.Windows.Forms.TextBoxBase
Class.
28-11-2014 ANKIT VERMA 22
Textbox : Properties & Methods
 Textbox Properties & Methods:
 Borderstyle
 MaxLength
 PasswordChar
 ReadOnly
 MultiLine
 Textbox Events:
 GotFocus
 LostFocus
 Click
 TextChanged
 KeyPress
28-11-2014 ANKIT VERMA 23
 ScrollBars
 SelectedText
 TextAlign
 WordWrap
 AppendText
 Text
 Clear
 Select
 SelectAll
 Show
 Cut
 Copy
 Paste
Textbox : Example
 Example:
28-11-2014 ANKIT VERMA 24
28-11-2014 ANKIT VERMA 25
Link Label
Link Label
 Used to support hyperlinks.
 Derived from Label class.
 Link Label Properties:
 ActiveLinkColor
 LinkColor
 VisitedLinkColor
 LinkVisited
 Link Label Event:
 LinkClicked
28-11-2014 ANKIT VERMA 26
Link Label : Example
 Example:
28-11-2014 ANKIT VERMA 27
28-11-2014 ANKIT VERMA 28
Button
Button
 Buttons are the controls which are used for click even.
 Button Properties:
 Text
 BackgroundImage
 ImageAlign
 TextAlign
 Button Event:
 Click
28-11-2014 ANKIT VERMA 29
28-11-2014 ANKIT VERMA 30
Radio Button &
Check Box
Radio Button
 Radio button is used to select any one option at time.
 These buttons are working in a group.
 GroupBox control is used to group the related controls
together.
 If we select a radio button from the group, the other
buttons can’t be select from the same group.
28-11-2014 ANKIT VERMA 31
Radio Button : Properties & Event
 Radio Button Properties:
 Text
 AutoCheck
 Radio Button Event:
 Click
28-11-2014 ANKIT VERMA 32
CheckBox
 Checkbox is used to set yes/no or true/false options.
 User can select one option at a time.
 When we select a checkbox, a right mark appears in it,
indicating that the box is selected.
 The image and text both can be displayed in the
CheckBox control.
28-11-2014 ANKIT VERMA 33
CheckBox : Properties & Event
 CheckBox Properties:
 Text
 AutoCheck
 Checked
 ThreeState
 CheckState
 CheckBox Event:
 CheckedChanged
28-11-2014 ANKIT VERMA 34
RadioButton & CheckBox : Example
 Example:
28-11-2014 ANKIT VERMA 35
RadioButton & CheckBox : Example
28-11-2014 ANKIT VERMA 36
RadioButton & CheckBox : Example
28-11-2014 ANKIT VERMA 37
RadioButton & CheckBox : Example
28-11-2014 ANKIT VERMA 38
28-11-2014 ANKIT VERMA 39
List Box &
Combo Box
ListBox
 Display list of items to user.
 User can select one or more items from list box.
 Scroll bar appears automatically if the list has too
many items.
 User can add items to control using Design Time or
Run Time.
28-11-2014 ANKIT VERMA 40
ListBox : Properties & Events
 ListBox Properties:
 SelectionMode
 Sorted
 SelectedIndex
 SelectedItem
 MultiColumn
 Items
 Add
 ListBox Event:
 SelectedIndexChanged
28-11-2014 ANKIT VERMA 41
 Clear
 Contains
 Insert
 IndexOf
 Remove
 RemoveAt
ComboBox
 It is used to display a drop down list of items.
 It is combination of a textbox in which user enters an
item & drop down list from which user selects an item.
28-11-2014 ANKIT VERMA 42
ComboBox : Properties & Events
 ComboBox Properties:
 Sorted
 MaxLength
 SelectedIndex
 SelectedItem
 Items
 Text
 Add
 ComboBox Event:
 SelectedIndexChanged
28-11-2014 ANKIT VERMA 43
 Clear
 Contains
 Insert
 IndexOf
 Remove
 RemoveAt
ListBox & ComboBox : Example
 Example:
28-11-2014 ANKIT VERMA 44
ListBox & ComboBox : Example
28-11-2014 ANKIT VERMA 45
ListBox & ComboBox : Example
28-11-2014 ANKIT VERMA 46
28-11-2014 ANKIT VERMA 47
Picture Box &
Timer Control
PictureBox
 Used to display images, handling images, editing
images.
 Image can be added at Run Time as well as at Design
Time.
 PictureBox Properties & Methods:
 Image
 BorderStyle
 SizeMode
 Load
 PictureBox Event:
 MouseDown
28-11-2014 ANKIT VERMA 48
Timer Control
 Used to create periodic events.
 This control is not visible at Run Time.
 It work behind the scenes.
 TimerControl Properties & Methods:
 Enable
 Interval
 Start
 Stop
 TimerControl Event:
 Tick
28-11-2014 ANKIT VERMA 49
PictureBox & Timer Control : Example
 Example:
28-11-2014 ANKIT VERMA 50
PictureBox & Timer Control : Example
28-11-2014 ANKIT VERMA 51
PictureBox & Timer Control : Example
28-11-2014 ANKIT VERMA 52
28-11-2014 ANKIT VERMA 53
HScrollBar &
VScrollBar
HScrollBar & VScrollBar
 Scroll Bars are Vertical & Horizontal controls that display a
Srcoll Box or Thumb that we can manipulate.
 The value of Scroll Bar changes when we drag the Thumb into
new position.
 ScrollBar Properties:
 Value
 Minimum
 Maximum
 LargeChange
 SmallChange
 ScrollBar Event
 ScrollValueChanged:
28-11-2014 ANKIT VERMA 54
HScrollBar : Example
 Example:
28-11-2014 ANKIT VERMA 55
28-11-2014 ANKIT VERMA 56
Panel
Panel
 Panel is used to group other controls.
 It divide the form into different regions.
 Panel Control have scrollbars.
 Panel Control Properties:
 AutoScroll
 BorderStyle
28-11-2014 ANKIT VERMA 57
Panel
 Example:
28-11-2014 ANKIT VERMA 58
28-11-2014 ANKIT VERMA 59
Menus
Menus
 Provide consistent way to group commands so that
user can access them very easily.
 MenuScript control is used to create menus.
 Menus are user friendly and interactive.
 Menu Item Properties:
 Checked
 DisplayStyle
 Enable
 ShortCutKeys
 Visible
28-11-2014 ANKIT VERMA 60
Menus
 Example:
28-11-2014 ANKIT VERMA 61
28-11-2014 ANKIT VERMA 62
Exception Handling
Exception Handling : Types
 Types of Exception Handling
 Structured Exception Handling
 Structured Exception Handling is included in VB.NET
 E.g. When we open a file & file not exist, exception raised and
handled by system itself.
 Un-structured Exceptional Handling
 Un-structured Exceptional Handling of Visual Basic is still
supported in VB.NET.
 Exception class in system namespace is base class of
all Exceptions.
28-11-2014 ANKIT VERMA 63
Exception Handling : Error Types
 Three types of Errors:
 Syntax
 Appear when we write the wrong Syntax.
 Easily fixed in .NET
 Runtime
 Appear only when we Compile & Run the code.
 Logical
 Appear when we use the application, but producing wrong result.
28-11-2014 ANKIT VERMA 64
Exception Handling : System Defined
 System defined exceptions are:
 Exception
 Index Out Of Range Exception
 Null Reference Exception
 Argument Exception
 Arithmetic Exception
28-11-2014 ANKIT VERMA 65
Exception Handling : Syntax
 Syntax:
Try
Catch [exception as type]
Catch [exception as type]
Finally
[finally statement]
End Try
28-11-2014 ANKIT VERMA 66
Exception Handling
 Example:
28-11-2014 ANKIT VERMA 67
User Defined Exception
 Example:
28-11-2014 ANKIT VERMA 68
28-11-2014 ANKIT VERMA 69
ADVANCED CONTROLS
28-11-2014 ANKIT VERMA 70
List View
List View
 Used to display items.
 E.g. Window Explorer right pane
 User can view items in different modes:
 LargeIcon
 SmallIcon
 List
 Title
 Details
28-11-2014 ANKIT VERMA 71
List View : Properties & Methods
 ListView Properties & Methods:
 AllowColumnReorder
 AutoArrange
 CheckBoxes
 Columns
 GridLines
 Items
 LabelEdit
 ListView Event:
 SelectedIndexChanged
28-11-2014 ANKIT VERMA 72
 MultiSelect
 Sorting
 View
 ArrangeIcons
 Clear
 GetItemAt
List View : Example
 Example:
28-11-2014 ANKIT VERMA 73
List View : Example
 Example:
28-11-2014 ANKIT VERMA 74
28-11-2014 ANKIT VERMA 75
Tree View
Tree View
 Display hierarchy of nodes.
 Each node can have child nodes also.
 E.g. Window explorer leftpane
28-11-2014 ANKIT VERMA 76
Tree View : Properties & Events
 TreeView Properties & Methods:
 CheckBoxes
 FullRowSelcet
 LabelEdit
 Nodes
 Scrollable
 SelectedNode
 GetNodeCount
 TreeView Events:
 AfterCollapse
 BeforeCollapse
28-11-2014 ANKIT VERMA 77
 ShowLines
 ShowRootLines
 Sorted
 TopNode
 CollapseAll
 ExpandAll
 AfterExpand
 BeforeExpand
Tree View : Example
 Example:
28-11-2014 ANKIT VERMA 78
28-11-2014 ANKIT VERMA 79
ToolBar
ToolBar
 Placed after menu bar & consist of buttons.
 Different types of buttons can be created in toolbar.
 Standard Push Button
 Toggle Button
 Drop Down Button
 Separators
 Toolbar are usually docked along the top of its parent
window.
 Display tool tips when the user points the mouse
pointer at toolbar button.
28-11-2014 ANKIT VERMA 80
ToolBar : Properties & Events
 ToolBar Properties & Methods:
 Appearance
 AutoSize
 Buttons
 Divider
 ShowToolTips
 TextAlign
 Wrappable
 ToolBar Events:
 ButtonClick
28-11-2014 ANKIT VERMA 81
28-11-2014 ANKIT VERMA 82
Status Bar
StatusBar
 Appear at bottom of window.
 Display panels or simple status bar to display single
message on bar.
 StatusBar Properties & Methods:
 BackgroundImage
 Font
 Panels
 ShowPanels
 StatusBar Events:
 PanelClick
28-11-2014 ANKIT VERMA 83
28-11-2014 ANKIT VERMA 84
Common Dialog Control
Common Dialog Control
 Window application use standard dialog boxes for
common operations.
 These are implemented as standard control in toolbox.
 They are not visible at Run Time.
 Five types of dialog controls in toolbox under dialog
tabs:
 ColorDialog
 FolderBrowserDialog
 FontDialog
 OpenFileDialog
 SaveFileDialog
28-11-2014 ANKIT VERMA 85
Common Dialog Control : Color Dialog
 Color Dialog is for selecting colors from list of colors.
 ColorDialog Properties & Methods:
 Color
 CustomColors
 FullOpen
 ShowHelp
 Reset
 ShowDialog
28-11-2014 ANKIT VERMA 86
Common Dialog Control : Folder Browser Dialog
 Folder Browser Dialog is used to select the folder.
 FolderBrowserDialog Properties & Methods:
 RootFolder
 SelectPath
 ShowNewFolderButton
 Reset
 ShowDialog
28-11-2014 ANKIT VERMA 87
Common Dialog Control : Font Dialog
 Font Dialog is similar to Font Dialog of MS Word.
 User can Select the font, style etc.
 FontDialog Properties & Methods:
 Color
 Font
 MaxSize
 MinSize
 ShowApply
 ShowColor
 ShowHelp
 Reset
 ShowDialog
28-11-2014 ANKIT VERMA 88
Color Dialog & Font Dialog : Example
 Example:
28-11-2014 ANKIT VERMA 89
Common Dialog Control
28-11-2014 ANKIT VERMA 90
Common Dialog Control :
Open File Dialog & Save File Dialog
 OpenFileDialog is used for selection of file to open.
 SaveFileDialog is used to select or specify the path of a
file in which current document will be saved.
 Properties & Methods:
 AddExtension
 DefaultExt
 FileName
 Filter
 MultiSelect
28-11-2014 ANKIT VERMA 91
 OpenFile
 Reset
 ShowDialog
 ShowReadOnly
 Show Help
Folder Browser Dialog : Example
 Example:
28-11-2014 ANKIT VERMA 92
28-11-2014 ANKIT VERMA 93
Creating User Controls
Creating User Controls
 All windows form controls are reusable components
and they are used for window based application.
 We can create our own control other than existing.
 We can combine existing & our own custom control.
 Two main classes used for creating custom controls:
 Control Class
 Provide all basic functionality for the windows user.
 Handles user input through keyboard, mouse etc.
 User Class
 It is inherited child of control class.
 Provide empty control that can be used to create other control.
28-11-2014 ANKIT VERMA 94
Creating User Controls : Types Of Controls
 There are three types of controls that can be created:
 Composite Control
 It is collection of Windows Form controls contained in single
container.
 Also called Constituent Controls.
 Extended Control
 In this, we derive an inherited control from the existing one.
 In this approach, we can retain all the functionality of parent control
and extend those functionality by adding our own custom properties
& methods.
 Custom Control
 This is new control from the beginning by inheriting from Control
Class.
28-11-2014 ANKIT VERMA 95
Creating User Controls : Example
 Creating User Control (Button):
28-11-2014 ANKIT VERMA 96
Creating User Controls : Example
 Import User Control (Button):
28-11-2014 ANKIT VERMA 97
Creating User Controls : Example
28-11-2014 ANKIT VERMA 98
Creating User Controls : Example
28-11-2014 ANKIT VERMA 99
Creating User Controls : Example
28-11-2014 ANKIT VERMA 100
28-11-2014 ANKIT VERMA 101
OBJECT ORIENTED
CONCEPTS
Object Oriented Concepts
 VB.NET is an Object Oriented Programming language
with features:
 Abstraction
 Encapsulation
 Polymorphism
 Inheritance
 It also support following:
 Overloading
 Overriding
 Structure
 Class
28-11-2014 ANKIT VERMA 102
Class
 Class is generally called a Blueprint or User Defined
Data Type.
 Class is collection of objects of similar type.
 Class consists of Attributes (Data Members) and
Behaviors (Member Functions), that are used by
Instances of that class.
 Class is an Abstract entity.
 Members of Class:
 Data Members, Properties, Methods & Events
 Class Access Specifiers:
 Public, Private, Protected, Friend & Protected Friend
28-11-2014 ANKIT VERMA 103
Object
 Objects are Real Time entity.
 They may present as Person, Place, Bank Account, Table of
Data, Item etc.
 It is Instance of class.
 Each object contain data & code to manipulate data.
 Two types of data members:
 Static or Class Member
 Members that apply to Class and called by their class names.
 Shared keyword is used with members.
 Instance or Object Member
 Members that apply to object.
 They referred by object name.
28-11-2014 ANKIT VERMA 104
Overloading & Overriding
 Overloading
 Provide different versions of a method that has same name &
different parameters.
 Parameters can be different from name, data type or ordering of
parameters.
 Overriding
 Replace inherited property or method.
 Overridden methods in subclass must be same as base class
method including name and parameters.
28-11-2014 ANKIT VERMA 105
Class Object Example
 Example:
28-11-2014 ANKIT VERMA 106
Constructor
 Special methods that allow control over initialization
of objects.
 Constructors are Procedures with name Sub New.
 Run when Instance of class is created.
 Explicitly called only from other Constructors.
 Parameterized Constructors:
 Parameters can be passed to constructors also.
 Shared Constructors can’t have parameters.
28-11-2014 ANKIT VERMA 107
Constructor Types
 Two types of Constructors:
 Shared Constructors
 Used to initialize Shared variables.
 Created using Shared keyword & shared with all instance of class.
 Not run more than one, during single execution of program.
 Explicitly Public access & we can’t write explicitly.
 We can’t initialize Instance variable in Constructor.
 Instance Constructors
 Initialize variable that are declared with Dim, Public, Private,
Friend, Protected etc.
 You can also access Shared variable within this.
28-11-2014 ANKIT VERMA 108
Constructor Example
28-11-2014 ANKIT VERMA 109
Destructor
 Special method used to release Objects from memory.
 Two types of Destructors:
 Finalize Method
 Called from the class or derived class, to which it belong.
 Called after last reference to an Object is released from Memory.
 .NET automatically runs Finalize Destructor.
 We can’t determine it’s execution, when an Object loses its scope.
 CLR calls this using system call called Garbage Collection.
 CLR periodically check for Object, if Object not used, this Destructor
is called automatically and Garbage Collection Starts.
 Finalize method is Overridden when we write our code Explicitly.
 Dispose
28-11-2014 ANKIT VERMA 110
Destructor
 Dispose Method
 Problem with Finalize Method is non deterministic nature.
 We can’t determine Finalize Method call explicitly.
 Dispose Method is called to release resource such as Database
Connection, File Handler or System Lock.
 Unlike Finalize Method, this is not called Automatically.
 Through code we have to call this Explicitly.
28-11-2014 ANKIT VERMA 111
 Example:
Protected Overrides Sub Finalize ( )
MsgBox (“Object Out Of Scope”)
EndSub
Structure
 It is User Defined Data Type.
 Structure combines Variables & Methods.
 Single Variable of Structure can hold different types of data.
 Structure can be declared Inside Class, Namespace, Module
or Another Structure.
 Access Specifiers are allowed for Structure & their members.
 Only Shared Members & Constants can be Initialized.
 Like Class, Structure have Constructors but only
parameterized.
 If we have Default Constructor, that must be declared as Shared one.
28-11-2014 ANKIT VERMA 112
Structure Example
 Example:
28-11-2014 ANKIT VERMA 113
Structure With Constructor Example
 Example:
28-11-2014 ANKIT VERMA 114
Class VS Structure
 Similarities:
 Both are User Defined Data Types.
 Both support members like Constructor, Variables, Constants,
Methods, Events etc.
 Both have Shared Constructors with or without parameters.
 Both can implement Interfaces.
28-11-2014 ANKIT VERMA 115
Class vs Structure
 Differences:
 Class can be Inherited from other Class, but Structure not.
 Class can have Instance Constructors with and without
parameters, but Structure only have parameterized.
 Class is Reference type, but Structure is Value type.
 Class allow initialization of members inside Class, but Structure
not allow inside initialization.
 Class have Private as default Access Specifier for all variables &
constants, but Structure have Public by default.
 Class Procedures can handle Events, but not in Structure.
28-11-2014 ANKIT VERMA 116
28-11-2014 ANKIT VERMA 117
Method Overloaing
Method Overloading
 Overloading Methods have same name, but different
argument lists.
 Argument may differ in Type, Number or Order Of
The Parameter.
 Return type of Overloading Method can be Same or
Different.
 Method invoked depends upon the type of argument
passed.
 Overloading is example of Polymorphism.
28-11-2014 ANKIT VERMA 118
Method Overloading : Example
28-11-2014 ANKIT VERMA 119
28-11-2014 ANKIT VERMA 120
Shared Members
Shared Members
 Shared keyword can be used with Constructor,
Methods & Variables.
 Shared methods can be overloaded like regular
methods.
 Shared variables create only one copy for all instances
of class.
28-11-2014 ANKIT VERMA 121
Shared Members : Example
 Example:
28-11-2014 ANKIT VERMA 122
28-11-2014 ANKIT VERMA 123
Inheritance
Inheritance
 Inheritance refers to deriving new Class from existing Class.
 Derived Class is known as Sub Class and Parent Class is
known as Base Class.
 Derived Class inherits all Public & Protected Data Members,
Methods, Events & Constants.
 Constructor can’t be inherited.
 Types of Inheritance:
 Single
 Multi Level
 Hierarchical
 Multiple Inheritance only supported by using Interface
28-11-2014 ANKIT VERMA 124
Inheritance : Keywords
 Inherits
 Inherits keyword is used to inherit Class.
 MustInherit
 Indicate that Class must be inherited by other Class.
 It act as Base Class and similar to Abstract Class of Java.
 NonInheritable
 If class is marked NonInheritable, we can’t create its Sub Class
 MyBase
 Call parent Class Constructor and Parent Class Overridden Methods.
 It always refers the immediate Super Class.
 We can’t navigate to more than one level from the Child Class.
 MyBase.MethodName is not allowed in .NET
28-11-2014 ANKIT VERMA 125
Inheritance : Keywords
 Overloads
 Indicate that methods are Overloading.
 If Methods are in same class, no necessary to write this keyword.
 Overridable
 Allow method to be Overridden.
 Overrides keyword is used to override the Overridable Method.
 NotOverridable
 Prevent the method being Overridden.
 MustOverride
 Methods must be declared in MultiInherit Class.
 MustInherit
 Enable Abstract Class creation. Child Class must implement all Abstract
Methods, otherwise Child Class also must declared as Abstract Class.
28-11-2014 ANKIT VERMA 126
Inheritance : Example
 Example:
28-11-2014 ANKIT VERMA 127
Inheritance : Example
28-11-2014 ANKIT VERMA 128
Inheritance : Example
28-11-2014 ANKIT VERMA 129
28-11-2014 ANKIT VERMA 130
Method Overriding
Method Overriding
 Sub Class is not only Inheriting but it can also give its
own implementation (override) for methods.
 All the methods can’t be Overridden.
 To allow methods to Overridden, Parent Class method
must use Overridable keyword.
28-11-2014 ANKIT VERMA 131
Method Overriding : Example
28-11-2014 ANKIT VERMA 132
28-11-2014 ANKIT VERMA 133
Abstract
Base Class
Abstract Base Class
 MustInherit keyword is used to create Abstract Class.
 Contain Signature of method, that Derived Class can
implement in its own Class.
 We can’t create Object of it.
 Method with MustOverride keyword should not
contain any implementation.
 Class with even one MustOverride method, should be
declared as MustInherit.
 To implement method, Overrides keyword use in Sub
Class.
28-11-2014 ANKIT VERMA 134
Abstract Base Class
 If Sub Class is not implementing any one of Abstract
methods from Abstract Class, then Child Class must
be declared as Abstract one.
 Abstract Class can contain Non-Abstract Method also.
28-11-2014 ANKIT VERMA 135
Abstract Base Class : Example
 Example:
28-11-2014 ANKIT VERMA 136
28-11-2014 ANKIT VERMA 137
Interface
Interface
 Interface defines Properties, Method and Events, called
members of Interface.
 Interface consist of only Declaration of Members but not
the Implementation.
 Only Class and Structure implement these data
members.
 Variables can’t be declared in the Interface.
 Single Class can inherit from only one Base Class, but
can implement any number of Interfaces.
 It support Multiple Inheritance.
 Implements keyword is used for their implementation.
28-11-2014 ANKIT VERMA 138
Interface Vs Class
 Interface can’t provide any implementation, whereas
Class can provide implementation to Methods.
 Interface can’t have Constructors, but Class can define
Constructors.
 A Class inherits from only one Class, but implements
multiple Interface.
28-11-2014 ANKIT VERMA 139
Interface : Example
 Example:
28-11-2014 ANKIT VERMA 140
THANKYOU
P R E S E N T A T I O N B Y :
A N K I T V E R M A
( I T D E P A R T M E N T )
DOUBTS
A N K I T V E R M A A S S T . P R O F E S S O R

BCA IPU VB.NET UNIT-III

  • 1.
    FEDT VB.NET F RO N T E N D D E S I G N T O O L U S I N G V B . N E T P R E S E N T A T I O N B Y : A N K I T V E R M A ( I T D E P A R T M E N T ) A N K I T V E R M A A S S T . P R O F E S S O R U N I T - 3
  • 2.
    Interface  User interactswith application using well-defined user interface.  Two types of interface:  CUI (Character User Interface)  Commands for user interaction  Not much user friendly  E.g. Console Application  GUI (Graphical User Interface)  No need to remember commands  Very easy to use & user friendly  E.g. Windows Application 28-11-2014 ANKIT VERMA 2
  • 3.
    28-11-2014 ANKIT VERMA3 WINDOWS FORMS
  • 4.
    Windows Form  Acceptinput from user & display information.  Develop desktop based application.  Provides full support of database connectivity & image formats.  System.Windows.Forms namespace support Form Class.  Title Bar, Menu Bar & Control Box are at top of form.  Main area is called Client Area, surrounded by border.  Form associated controls enriched with predefined Properties, Methods & Events. 28-11-2014 ANKIT VERMA 4
  • 5.
    Windows Form  Properties Define characteristics of controls like color, size, border etc.  Methods  Methods are defined by the action that an object can perform.  Events  These are actions that can be recognized by the objects.  Event occur when the user, OS or application interact with objects of program.  They control the appearance & behavior of a form either at design time or run time. 28-11-2014 ANKIT VERMA 5
  • 6.
    Windows Form: Properties& Methods  Backcolor  BackgroundImage  FormBorderStyle  None  Fixed Single  Sizeable  Fixed Dialog  Fixed 3D  Fixed Tool Window  Sizeable Tool Window  MaximizeBox 28-11-2014 ANKIT VERMA 6
  • 7.
    Windows Form: Properties& Methods  MaximizeBox  MinimizeBox  Text  WindowState  StartPosition  CenterParent  Manual  CenterScreen  WindowDefaultBounds  WindowDefaultLocation 28-11-2014 ANKIT VERMA 7
  • 8.
    Windows Form: Properties& Methods  Activate  Close  Show  Refresh  Hide  Dispose 28-11-2014 ANKIT VERMA 8
  • 9.
    Windows Form :Example  Example 1: 28-11-2014 ANKIT VERMA 9
  • 10.
    Windows Form :Example  Example 2: 28-11-2014 ANKIT VERMA 10
  • 11.
    Windows Form: Events Activated  Deactivate  Click  Load  Closing  Closed 28-11-2014 ANKIT VERMA 11
  • 12.
    MDI Forms  Displaymultiple windows at same time.  MDI form act as parent form or container for all other forms, called MDI parent form.  Contain Menu Bar, Tool Bar and Status Bar.  E.g. Word  By default, VB.NET support SDI application, where only one window displayed at a time.  E.g. Wordpad  In MDI Application, child forms are displayed as independent windows under parent MDI window. 28-11-2014 ANKIT VERMA 12
  • 13.
    MDI Forms  Createa form & set IsMDIContainer property true, it will act as container.  Attach the menus to MIDI parent form.  Click event of menu item, write: Form2.Show()  Add one more Form to project.  Write code on load of Second Form: Me.MdiParent = Form1  Run the code & click on menu item. 28-11-2014 ANKIT VERMA 13
  • 14.
  • 15.
  • 16.
    Controls  Major controlsare:  Label  Linklabel  Textbox  Button  Checkbox  Listbox  Radiobutton  Combobox  Groupbox  Hscrollbar 28-11-2014 ANKIT VERMA 16  Vscrollbar  Picturebox  Timer  ListView  TreeView  Panel  ToolBar  StatusBar
  • 17.
    Controls : Properties& Methods  Properties & Methods of controls are:  Backcolor  Forecolor  Size  Enable  Locked  Visible  Location  Font  Maximum Size  Minimum Size 28-11-2014 ANKIT VERMA 17  Hide  Show  Select  Refresh
  • 18.
  • 19.
    Label  Graphic controlused to display text.  User can’t edit text directly.  Text properties can be set at Run Time / Design Time.  It is in System.Windows.Form.Label class.  Label can’t receive focus.  Label Properties are:  AutoSize  BorderStyle  Enabled  Text Align  Text 28-11-2014 ANKIT VERMA 19
  • 20.
    Label : Example Example: 28-11-2014 ANKIT VERMA 20
  • 21.
  • 22.
    Textbox  Accept inputfrom user & retrieve data from database.  Textbox can be Multiline, Editable or ReadOnly.  It is subclass of System.Windows.Forms.TextBoxBase Class. 28-11-2014 ANKIT VERMA 22
  • 23.
    Textbox : Properties& Methods  Textbox Properties & Methods:  Borderstyle  MaxLength  PasswordChar  ReadOnly  MultiLine  Textbox Events:  GotFocus  LostFocus  Click  TextChanged  KeyPress 28-11-2014 ANKIT VERMA 23  ScrollBars  SelectedText  TextAlign  WordWrap  AppendText  Text  Clear  Select  SelectAll  Show  Cut  Copy  Paste
  • 24.
    Textbox : Example Example: 28-11-2014 ANKIT VERMA 24
  • 25.
  • 26.
    Link Label  Usedto support hyperlinks.  Derived from Label class.  Link Label Properties:  ActiveLinkColor  LinkColor  VisitedLinkColor  LinkVisited  Link Label Event:  LinkClicked 28-11-2014 ANKIT VERMA 26
  • 27.
    Link Label :Example  Example: 28-11-2014 ANKIT VERMA 27
  • 28.
  • 29.
    Button  Buttons arethe controls which are used for click even.  Button Properties:  Text  BackgroundImage  ImageAlign  TextAlign  Button Event:  Click 28-11-2014 ANKIT VERMA 29
  • 30.
    28-11-2014 ANKIT VERMA30 Radio Button & Check Box
  • 31.
    Radio Button  Radiobutton is used to select any one option at time.  These buttons are working in a group.  GroupBox control is used to group the related controls together.  If we select a radio button from the group, the other buttons can’t be select from the same group. 28-11-2014 ANKIT VERMA 31
  • 32.
    Radio Button :Properties & Event  Radio Button Properties:  Text  AutoCheck  Radio Button Event:  Click 28-11-2014 ANKIT VERMA 32
  • 33.
    CheckBox  Checkbox isused to set yes/no or true/false options.  User can select one option at a time.  When we select a checkbox, a right mark appears in it, indicating that the box is selected.  The image and text both can be displayed in the CheckBox control. 28-11-2014 ANKIT VERMA 33
  • 34.
    CheckBox : Properties& Event  CheckBox Properties:  Text  AutoCheck  Checked  ThreeState  CheckState  CheckBox Event:  CheckedChanged 28-11-2014 ANKIT VERMA 34
  • 35.
    RadioButton & CheckBox: Example  Example: 28-11-2014 ANKIT VERMA 35
  • 36.
    RadioButton & CheckBox: Example 28-11-2014 ANKIT VERMA 36
  • 37.
    RadioButton & CheckBox: Example 28-11-2014 ANKIT VERMA 37
  • 38.
    RadioButton & CheckBox: Example 28-11-2014 ANKIT VERMA 38
  • 39.
    28-11-2014 ANKIT VERMA39 List Box & Combo Box
  • 40.
    ListBox  Display listof items to user.  User can select one or more items from list box.  Scroll bar appears automatically if the list has too many items.  User can add items to control using Design Time or Run Time. 28-11-2014 ANKIT VERMA 40
  • 41.
    ListBox : Properties& Events  ListBox Properties:  SelectionMode  Sorted  SelectedIndex  SelectedItem  MultiColumn  Items  Add  ListBox Event:  SelectedIndexChanged 28-11-2014 ANKIT VERMA 41  Clear  Contains  Insert  IndexOf  Remove  RemoveAt
  • 42.
    ComboBox  It isused to display a drop down list of items.  It is combination of a textbox in which user enters an item & drop down list from which user selects an item. 28-11-2014 ANKIT VERMA 42
  • 43.
    ComboBox : Properties& Events  ComboBox Properties:  Sorted  MaxLength  SelectedIndex  SelectedItem  Items  Text  Add  ComboBox Event:  SelectedIndexChanged 28-11-2014 ANKIT VERMA 43  Clear  Contains  Insert  IndexOf  Remove  RemoveAt
  • 44.
    ListBox & ComboBox: Example  Example: 28-11-2014 ANKIT VERMA 44
  • 45.
    ListBox & ComboBox: Example 28-11-2014 ANKIT VERMA 45
  • 46.
    ListBox & ComboBox: Example 28-11-2014 ANKIT VERMA 46
  • 47.
    28-11-2014 ANKIT VERMA47 Picture Box & Timer Control
  • 48.
    PictureBox  Used todisplay images, handling images, editing images.  Image can be added at Run Time as well as at Design Time.  PictureBox Properties & Methods:  Image  BorderStyle  SizeMode  Load  PictureBox Event:  MouseDown 28-11-2014 ANKIT VERMA 48
  • 49.
    Timer Control  Usedto create periodic events.  This control is not visible at Run Time.  It work behind the scenes.  TimerControl Properties & Methods:  Enable  Interval  Start  Stop  TimerControl Event:  Tick 28-11-2014 ANKIT VERMA 49
  • 50.
    PictureBox & TimerControl : Example  Example: 28-11-2014 ANKIT VERMA 50
  • 51.
    PictureBox & TimerControl : Example 28-11-2014 ANKIT VERMA 51
  • 52.
    PictureBox & TimerControl : Example 28-11-2014 ANKIT VERMA 52
  • 53.
    28-11-2014 ANKIT VERMA53 HScrollBar & VScrollBar
  • 54.
    HScrollBar & VScrollBar Scroll Bars are Vertical & Horizontal controls that display a Srcoll Box or Thumb that we can manipulate.  The value of Scroll Bar changes when we drag the Thumb into new position.  ScrollBar Properties:  Value  Minimum  Maximum  LargeChange  SmallChange  ScrollBar Event  ScrollValueChanged: 28-11-2014 ANKIT VERMA 54
  • 55.
    HScrollBar : Example Example: 28-11-2014 ANKIT VERMA 55
  • 56.
  • 57.
    Panel  Panel isused to group other controls.  It divide the form into different regions.  Panel Control have scrollbars.  Panel Control Properties:  AutoScroll  BorderStyle 28-11-2014 ANKIT VERMA 57
  • 58.
  • 59.
  • 60.
    Menus  Provide consistentway to group commands so that user can access them very easily.  MenuScript control is used to create menus.  Menus are user friendly and interactive.  Menu Item Properties:  Checked  DisplayStyle  Enable  ShortCutKeys  Visible 28-11-2014 ANKIT VERMA 60
  • 61.
  • 62.
    28-11-2014 ANKIT VERMA62 Exception Handling
  • 63.
    Exception Handling :Types  Types of Exception Handling  Structured Exception Handling  Structured Exception Handling is included in VB.NET  E.g. When we open a file & file not exist, exception raised and handled by system itself.  Un-structured Exceptional Handling  Un-structured Exceptional Handling of Visual Basic is still supported in VB.NET.  Exception class in system namespace is base class of all Exceptions. 28-11-2014 ANKIT VERMA 63
  • 64.
    Exception Handling :Error Types  Three types of Errors:  Syntax  Appear when we write the wrong Syntax.  Easily fixed in .NET  Runtime  Appear only when we Compile & Run the code.  Logical  Appear when we use the application, but producing wrong result. 28-11-2014 ANKIT VERMA 64
  • 65.
    Exception Handling :System Defined  System defined exceptions are:  Exception  Index Out Of Range Exception  Null Reference Exception  Argument Exception  Arithmetic Exception 28-11-2014 ANKIT VERMA 65
  • 66.
    Exception Handling :Syntax  Syntax: Try Catch [exception as type] Catch [exception as type] Finally [finally statement] End Try 28-11-2014 ANKIT VERMA 66
  • 67.
  • 68.
    User Defined Exception Example: 28-11-2014 ANKIT VERMA 68
  • 69.
    28-11-2014 ANKIT VERMA69 ADVANCED CONTROLS
  • 70.
  • 71.
    List View  Usedto display items.  E.g. Window Explorer right pane  User can view items in different modes:  LargeIcon  SmallIcon  List  Title  Details 28-11-2014 ANKIT VERMA 71
  • 72.
    List View :Properties & Methods  ListView Properties & Methods:  AllowColumnReorder  AutoArrange  CheckBoxes  Columns  GridLines  Items  LabelEdit  ListView Event:  SelectedIndexChanged 28-11-2014 ANKIT VERMA 72  MultiSelect  Sorting  View  ArrangeIcons  Clear  GetItemAt
  • 73.
    List View :Example  Example: 28-11-2014 ANKIT VERMA 73
  • 74.
    List View :Example  Example: 28-11-2014 ANKIT VERMA 74
  • 75.
  • 76.
    Tree View  Displayhierarchy of nodes.  Each node can have child nodes also.  E.g. Window explorer leftpane 28-11-2014 ANKIT VERMA 76
  • 77.
    Tree View :Properties & Events  TreeView Properties & Methods:  CheckBoxes  FullRowSelcet  LabelEdit  Nodes  Scrollable  SelectedNode  GetNodeCount  TreeView Events:  AfterCollapse  BeforeCollapse 28-11-2014 ANKIT VERMA 77  ShowLines  ShowRootLines  Sorted  TopNode  CollapseAll  ExpandAll  AfterExpand  BeforeExpand
  • 78.
    Tree View :Example  Example: 28-11-2014 ANKIT VERMA 78
  • 79.
  • 80.
    ToolBar  Placed aftermenu bar & consist of buttons.  Different types of buttons can be created in toolbar.  Standard Push Button  Toggle Button  Drop Down Button  Separators  Toolbar are usually docked along the top of its parent window.  Display tool tips when the user points the mouse pointer at toolbar button. 28-11-2014 ANKIT VERMA 80
  • 81.
    ToolBar : Properties& Events  ToolBar Properties & Methods:  Appearance  AutoSize  Buttons  Divider  ShowToolTips  TextAlign  Wrappable  ToolBar Events:  ButtonClick 28-11-2014 ANKIT VERMA 81
  • 82.
  • 83.
    StatusBar  Appear atbottom of window.  Display panels or simple status bar to display single message on bar.  StatusBar Properties & Methods:  BackgroundImage  Font  Panels  ShowPanels  StatusBar Events:  PanelClick 28-11-2014 ANKIT VERMA 83
  • 84.
    28-11-2014 ANKIT VERMA84 Common Dialog Control
  • 85.
    Common Dialog Control Window application use standard dialog boxes for common operations.  These are implemented as standard control in toolbox.  They are not visible at Run Time.  Five types of dialog controls in toolbox under dialog tabs:  ColorDialog  FolderBrowserDialog  FontDialog  OpenFileDialog  SaveFileDialog 28-11-2014 ANKIT VERMA 85
  • 86.
    Common Dialog Control: Color Dialog  Color Dialog is for selecting colors from list of colors.  ColorDialog Properties & Methods:  Color  CustomColors  FullOpen  ShowHelp  Reset  ShowDialog 28-11-2014 ANKIT VERMA 86
  • 87.
    Common Dialog Control: Folder Browser Dialog  Folder Browser Dialog is used to select the folder.  FolderBrowserDialog Properties & Methods:  RootFolder  SelectPath  ShowNewFolderButton  Reset  ShowDialog 28-11-2014 ANKIT VERMA 87
  • 88.
    Common Dialog Control: Font Dialog  Font Dialog is similar to Font Dialog of MS Word.  User can Select the font, style etc.  FontDialog Properties & Methods:  Color  Font  MaxSize  MinSize  ShowApply  ShowColor  ShowHelp  Reset  ShowDialog 28-11-2014 ANKIT VERMA 88
  • 89.
    Color Dialog &Font Dialog : Example  Example: 28-11-2014 ANKIT VERMA 89
  • 90.
  • 91.
    Common Dialog Control: Open File Dialog & Save File Dialog  OpenFileDialog is used for selection of file to open.  SaveFileDialog is used to select or specify the path of a file in which current document will be saved.  Properties & Methods:  AddExtension  DefaultExt  FileName  Filter  MultiSelect 28-11-2014 ANKIT VERMA 91  OpenFile  Reset  ShowDialog  ShowReadOnly  Show Help
  • 92.
    Folder Browser Dialog: Example  Example: 28-11-2014 ANKIT VERMA 92
  • 93.
    28-11-2014 ANKIT VERMA93 Creating User Controls
  • 94.
    Creating User Controls All windows form controls are reusable components and they are used for window based application.  We can create our own control other than existing.  We can combine existing & our own custom control.  Two main classes used for creating custom controls:  Control Class  Provide all basic functionality for the windows user.  Handles user input through keyboard, mouse etc.  User Class  It is inherited child of control class.  Provide empty control that can be used to create other control. 28-11-2014 ANKIT VERMA 94
  • 95.
    Creating User Controls: Types Of Controls  There are three types of controls that can be created:  Composite Control  It is collection of Windows Form controls contained in single container.  Also called Constituent Controls.  Extended Control  In this, we derive an inherited control from the existing one.  In this approach, we can retain all the functionality of parent control and extend those functionality by adding our own custom properties & methods.  Custom Control  This is new control from the beginning by inheriting from Control Class. 28-11-2014 ANKIT VERMA 95
  • 96.
    Creating User Controls: Example  Creating User Control (Button): 28-11-2014 ANKIT VERMA 96
  • 97.
    Creating User Controls: Example  Import User Control (Button): 28-11-2014 ANKIT VERMA 97
  • 98.
    Creating User Controls: Example 28-11-2014 ANKIT VERMA 98
  • 99.
    Creating User Controls: Example 28-11-2014 ANKIT VERMA 99
  • 100.
    Creating User Controls: Example 28-11-2014 ANKIT VERMA 100
  • 101.
    28-11-2014 ANKIT VERMA101 OBJECT ORIENTED CONCEPTS
  • 102.
    Object Oriented Concepts VB.NET is an Object Oriented Programming language with features:  Abstraction  Encapsulation  Polymorphism  Inheritance  It also support following:  Overloading  Overriding  Structure  Class 28-11-2014 ANKIT VERMA 102
  • 103.
    Class  Class isgenerally called a Blueprint or User Defined Data Type.  Class is collection of objects of similar type.  Class consists of Attributes (Data Members) and Behaviors (Member Functions), that are used by Instances of that class.  Class is an Abstract entity.  Members of Class:  Data Members, Properties, Methods & Events  Class Access Specifiers:  Public, Private, Protected, Friend & Protected Friend 28-11-2014 ANKIT VERMA 103
  • 104.
    Object  Objects areReal Time entity.  They may present as Person, Place, Bank Account, Table of Data, Item etc.  It is Instance of class.  Each object contain data & code to manipulate data.  Two types of data members:  Static or Class Member  Members that apply to Class and called by their class names.  Shared keyword is used with members.  Instance or Object Member  Members that apply to object.  They referred by object name. 28-11-2014 ANKIT VERMA 104
  • 105.
    Overloading & Overriding Overloading  Provide different versions of a method that has same name & different parameters.  Parameters can be different from name, data type or ordering of parameters.  Overriding  Replace inherited property or method.  Overridden methods in subclass must be same as base class method including name and parameters. 28-11-2014 ANKIT VERMA 105
  • 106.
    Class Object Example Example: 28-11-2014 ANKIT VERMA 106
  • 107.
    Constructor  Special methodsthat allow control over initialization of objects.  Constructors are Procedures with name Sub New.  Run when Instance of class is created.  Explicitly called only from other Constructors.  Parameterized Constructors:  Parameters can be passed to constructors also.  Shared Constructors can’t have parameters. 28-11-2014 ANKIT VERMA 107
  • 108.
    Constructor Types  Twotypes of Constructors:  Shared Constructors  Used to initialize Shared variables.  Created using Shared keyword & shared with all instance of class.  Not run more than one, during single execution of program.  Explicitly Public access & we can’t write explicitly.  We can’t initialize Instance variable in Constructor.  Instance Constructors  Initialize variable that are declared with Dim, Public, Private, Friend, Protected etc.  You can also access Shared variable within this. 28-11-2014 ANKIT VERMA 108
  • 109.
  • 110.
    Destructor  Special methodused to release Objects from memory.  Two types of Destructors:  Finalize Method  Called from the class or derived class, to which it belong.  Called after last reference to an Object is released from Memory.  .NET automatically runs Finalize Destructor.  We can’t determine it’s execution, when an Object loses its scope.  CLR calls this using system call called Garbage Collection.  CLR periodically check for Object, if Object not used, this Destructor is called automatically and Garbage Collection Starts.  Finalize method is Overridden when we write our code Explicitly.  Dispose 28-11-2014 ANKIT VERMA 110
  • 111.
    Destructor  Dispose Method Problem with Finalize Method is non deterministic nature.  We can’t determine Finalize Method call explicitly.  Dispose Method is called to release resource such as Database Connection, File Handler or System Lock.  Unlike Finalize Method, this is not called Automatically.  Through code we have to call this Explicitly. 28-11-2014 ANKIT VERMA 111  Example: Protected Overrides Sub Finalize ( ) MsgBox (“Object Out Of Scope”) EndSub
  • 112.
    Structure  It isUser Defined Data Type.  Structure combines Variables & Methods.  Single Variable of Structure can hold different types of data.  Structure can be declared Inside Class, Namespace, Module or Another Structure.  Access Specifiers are allowed for Structure & their members.  Only Shared Members & Constants can be Initialized.  Like Class, Structure have Constructors but only parameterized.  If we have Default Constructor, that must be declared as Shared one. 28-11-2014 ANKIT VERMA 112
  • 113.
  • 114.
    Structure With ConstructorExample  Example: 28-11-2014 ANKIT VERMA 114
  • 115.
    Class VS Structure Similarities:  Both are User Defined Data Types.  Both support members like Constructor, Variables, Constants, Methods, Events etc.  Both have Shared Constructors with or without parameters.  Both can implement Interfaces. 28-11-2014 ANKIT VERMA 115
  • 116.
    Class vs Structure Differences:  Class can be Inherited from other Class, but Structure not.  Class can have Instance Constructors with and without parameters, but Structure only have parameterized.  Class is Reference type, but Structure is Value type.  Class allow initialization of members inside Class, but Structure not allow inside initialization.  Class have Private as default Access Specifier for all variables & constants, but Structure have Public by default.  Class Procedures can handle Events, but not in Structure. 28-11-2014 ANKIT VERMA 116
  • 117.
    28-11-2014 ANKIT VERMA117 Method Overloaing
  • 118.
    Method Overloading  OverloadingMethods have same name, but different argument lists.  Argument may differ in Type, Number or Order Of The Parameter.  Return type of Overloading Method can be Same or Different.  Method invoked depends upon the type of argument passed.  Overloading is example of Polymorphism. 28-11-2014 ANKIT VERMA 118
  • 119.
    Method Overloading :Example 28-11-2014 ANKIT VERMA 119
  • 120.
    28-11-2014 ANKIT VERMA120 Shared Members
  • 121.
    Shared Members  Sharedkeyword can be used with Constructor, Methods & Variables.  Shared methods can be overloaded like regular methods.  Shared variables create only one copy for all instances of class. 28-11-2014 ANKIT VERMA 121
  • 122.
    Shared Members :Example  Example: 28-11-2014 ANKIT VERMA 122
  • 123.
    28-11-2014 ANKIT VERMA123 Inheritance
  • 124.
    Inheritance  Inheritance refersto deriving new Class from existing Class.  Derived Class is known as Sub Class and Parent Class is known as Base Class.  Derived Class inherits all Public & Protected Data Members, Methods, Events & Constants.  Constructor can’t be inherited.  Types of Inheritance:  Single  Multi Level  Hierarchical  Multiple Inheritance only supported by using Interface 28-11-2014 ANKIT VERMA 124
  • 125.
    Inheritance : Keywords Inherits  Inherits keyword is used to inherit Class.  MustInherit  Indicate that Class must be inherited by other Class.  It act as Base Class and similar to Abstract Class of Java.  NonInheritable  If class is marked NonInheritable, we can’t create its Sub Class  MyBase  Call parent Class Constructor and Parent Class Overridden Methods.  It always refers the immediate Super Class.  We can’t navigate to more than one level from the Child Class.  MyBase.MethodName is not allowed in .NET 28-11-2014 ANKIT VERMA 125
  • 126.
    Inheritance : Keywords Overloads  Indicate that methods are Overloading.  If Methods are in same class, no necessary to write this keyword.  Overridable  Allow method to be Overridden.  Overrides keyword is used to override the Overridable Method.  NotOverridable  Prevent the method being Overridden.  MustOverride  Methods must be declared in MultiInherit Class.  MustInherit  Enable Abstract Class creation. Child Class must implement all Abstract Methods, otherwise Child Class also must declared as Abstract Class. 28-11-2014 ANKIT VERMA 126
  • 127.
    Inheritance : Example Example: 28-11-2014 ANKIT VERMA 127
  • 128.
  • 129.
  • 130.
    28-11-2014 ANKIT VERMA130 Method Overriding
  • 131.
    Method Overriding  SubClass is not only Inheriting but it can also give its own implementation (override) for methods.  All the methods can’t be Overridden.  To allow methods to Overridden, Parent Class method must use Overridable keyword. 28-11-2014 ANKIT VERMA 131
  • 132.
    Method Overriding :Example 28-11-2014 ANKIT VERMA 132
  • 133.
    28-11-2014 ANKIT VERMA133 Abstract Base Class
  • 134.
    Abstract Base Class MustInherit keyword is used to create Abstract Class.  Contain Signature of method, that Derived Class can implement in its own Class.  We can’t create Object of it.  Method with MustOverride keyword should not contain any implementation.  Class with even one MustOverride method, should be declared as MustInherit.  To implement method, Overrides keyword use in Sub Class. 28-11-2014 ANKIT VERMA 134
  • 135.
    Abstract Base Class If Sub Class is not implementing any one of Abstract methods from Abstract Class, then Child Class must be declared as Abstract one.  Abstract Class can contain Non-Abstract Method also. 28-11-2014 ANKIT VERMA 135
  • 136.
    Abstract Base Class: Example  Example: 28-11-2014 ANKIT VERMA 136
  • 137.
  • 138.
    Interface  Interface definesProperties, Method and Events, called members of Interface.  Interface consist of only Declaration of Members but not the Implementation.  Only Class and Structure implement these data members.  Variables can’t be declared in the Interface.  Single Class can inherit from only one Base Class, but can implement any number of Interfaces.  It support Multiple Inheritance.  Implements keyword is used for their implementation. 28-11-2014 ANKIT VERMA 138
  • 139.
    Interface Vs Class Interface can’t provide any implementation, whereas Class can provide implementation to Methods.  Interface can’t have Constructors, but Class can define Constructors.  A Class inherits from only one Class, but implements multiple Interface. 28-11-2014 ANKIT VERMA 139
  • 140.
    Interface : Example Example: 28-11-2014 ANKIT VERMA 140
  • 141.
    THANKYOU P R ES E N T A T I O N B Y : A N K I T V E R M A ( I T D E P A R T M E N T ) DOUBTS A N K I T V E R M A A S S T . P R O F E S S O R