Group Discounts available for 3+ students and Corporate Clients

Object Oriented Program Model in

Object Oriented Program Model:



Suppose an institute approached you to develop software. Let us see that many institutes will approach you to develop a website for them. You need not develop a specific project for every single rather than to develop a single project & edit.

In the above design we take an institute class and it contains courses offered since we know variety of courses and address is varies 1m to other institute.

Client is peers discount by default is R.S of if joining by group may be discount consists.


Event handling in .NET:


Event: These are the actions that are allowed on a control or an object.


For Ex: Click, Mouse Move etc.


Event handling:

These are the methods which provide the functionality or the task to be executed whenever an event has been raised on a control.

VB.Net supports two types of Event handlers

  • Static Event handlers
  • Dynamic Event handlers

Using console application for projecting a windows form

In order to use Windows Form “System.Windows.Forms.Form” class should be used.

Open console application

If we Write Imports System.Windows.Form //gives error

So go to project [menu] à add reference

In add reference menu select .NET & select System.Windows.Forms & press OK

Hence error is removed automatically

‘‘Demo on using console application to project win form

Imports System.Windows.Forms

Module Winform’’Demo

Class FClass

Inherits Form

End Class

Sub main ()

Dim fc as New FClass

fc.Text = “VB 270 WinForm ‘‘Demo”

fc.showDialog ()

End sub

End Module

  • Execute then we get a WinForm


Static Event handlers:

Whenever an event handler is defined for the objects or controls created at the design time then it is said to be Static Event Handler.



In order to bind a static Event Handler for, a control or an object then it is mandatory to create the objects using the “WithEvents” modifier.



Syntax to define a Static Event Handler:

Private sub ControlName_EventName (By Val sender as object, By Val e as xEveneArgs) handles ControlName.EventName


– – – – – – – –

End sub

Take a New Module

‘Demo on Static Event handling . . . .

Imports System.Windows.Forms

Module Static Event Handling Demo

Class FClass

Inherits Form

WithEvents t as New TextBox

Sub new ()

t.Multitime = true

t.ScrollBars = ScrollBars.Vertical

t.Dock = DockStyle.Fill

Me.Text = “StaticEventHandlingdemo”


End sub

Private sub t.Keypress (By Val sender As object, By Val e as KeyPressEventArgs)

Handles t.KeyPress

e.Handled = True ‘Nullify the Key Press (Don’t take p/p of user)

t.Text$ = “East or West .Net is best

So eat.Net, Drink.Net, sleep.Net, .Net simply rockzzzz”

End sub

End class

Sub main ()

Dim fc as New FClass

fc.ShowDialog ()

End sub

End Module


Dynamic Event Handlers:

Whenever an Event Handlers are being defined for the controls that are created at the runtime then it is said to be Dynamic Event Handling.


Syntax to add a Dynamic Event Handler:

AddHandler, ControlName.EventName, Address of Method Name



  • Any modifiers can be used for defining the objects.
  • Dynamic Event Handlers can be removed at run time but Static Event Handlers can’t be removed.
  • In order to remove a Dynamic Event Handler



RemoveHandler, ControlName.EventName, Address of MethodName

Take a New Module

‘Demo on Dynamic Event handling . . . .

Imports System.Windows.Forms

Module DynamicEventHandler

Class FClass

Inherits Form

Sub new ()

Dim f/p as new FlowLayoutPanel

For I as Integer = 1 to 5

Dim b as New button

b.Text = i

AddHandler, address of b_click



Me.Text = “DynamicEventHandlingDemo”

Me.Control.Add (fip)

End sub

Private sub b_click (By Val sender as object, By Val e as EventArgs)

Dim b as new button

B = (Type (sender, Button)

MessageBox.Show (“You have clicked” & b.Text, Me.Text)

End sub

End class

Sub main ()

Dim fc as New FClass

fc.ShowDialog ()

End sub

End Module







This is nothing but the object from which event is raised.

Ex: 1, 2, 3, 4, 5

Sender must be object so we must convert

We use C Type

C Type (Sender, Button)

It must be assign to b which means

  • Sender in the event handler maintains the object which has raised the event.



“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at, we will update the article in 24 hours.”

0 Responses on Object Oriented Program Model in"

Leave a Message

Your email address will not be published. Required fields are marked *


Please Enter Your Details and Query.
Three + 6