Вы находитесь на странице: 1из 18

Object Oriented Programming In VB.

NET - CodeProject

1 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

Not quite what you are looking for? You may want to try:

From Simple JavaScript Classes to ASP.NET AJAX Controls


OO Programming By Example

highlights off

10,647,570 members (44,632 online)

home

articles

quick answers

discussions

features

Sign in

community
oop vb

help
Articles Languages VB.NET General

Next

About Article

Article
Browse Code
Bugs / Suggestions
Stats

By Anoop Madhusudanan, 18 Nov 2004


4.60 (124 votes)

Rate this:

Revisions
Alternatives

Download source files - 10.7 Kb

Comments (48)

View this article's


Workspace
Fork this Workspace

Connect using Git

Share

Introduction
Using the code
Lesson 1: Namespaces, Classes & Modules
Lesson 2: Access Types
Lesson 3: Shared Functions
Lesson 4: Overloading
Lesson 5: Inheritance
Lesson 6: Overriding
Lesson 7: Polymorphism
Lesson 8: Constructors & Destructors
Lesson 9: Property Routines
Lesson 10: A Simple Application

VB.NET is completely object oriented. This article uncovers some basic Object Oriented
Programming features of Visual Basic. NET. The whole article is divided into ten lessons. The
source code for these lessons is provided with the article.
This tutorial is designed with the following objectives:
1. To provide a sound knowledge about Object Oriented Programming in VB.NET.
2. To educate how Object Oriented techniques are used in VB.NET.
3. To explain the following concepts in an easy and simple way:
Creating and using classes and objects in VB.NET.
Encapsulation, Abstraction, Inheritance and Polymorphism.
Overloading and Overriding.
Constructors and Destructors.
Static functions.

A must read for anyone


who is interested in VB.NET.
This article uncovers some
basic Object Oriented
Programming features of
Visual Basic .NET. The whole
article is divided into 10
lessons. The source code
for these lessons is
provided with the article.
Type

Article

Licence
First Posted

18 Nov 2004

Views

455,623

Bookmarked

227 times

.NET1.0 .NET1.1
.NET2.0 VS.NET2003 VB ,
+

Top News
China bans use of
Microsoft's Windows 8 on
government computers
Get the Insider News free each
morning.

Related Videos

Go through this tutorial and you will start making sense of almost any .NET code. Also, Java/CPP
programmers can use this to understand OOPs in VB.NET.

The source code for each lesson is available as a .vb source code file. You need Microsoft .NET

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

2 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

framework SDK installed in your system to compile and execute the exercises in this article. You
can download it from the Microsoft website. The VB.NET compiler (vbc.exe) normally resides in
your FrameworkSDK\bin folder.
To manually compile a source code file, you may use the command prompt to type: vbc
filename.vb /out:"filename.exe" /r:"System.Windows.Forms.dll","System.dll"

Related Articles
From Simple JavaScript Classes
to ASP.NET AJAX Controls
OO Programming By Example
Status List
IDEAL CHALK - mnemonic
acronym and mnemonic images
for Object Oriented Principles
(OOP)
Call a Web Service Without
Adding a Web Reference

A Namespace

The Dark Shadow of Overrides

In VB.NET, classes and other data structures for a specific purpose are grouped together
to form a namespace. You can use the classes in a namespace, by simply importing the
namespace. The Imports keyword is used to import a namespace to your project. .NET
framework provides a rich set of built in classes, grouped together to various namespaces.
In this lesson, we are using the System namespace. Import the System namespace
(already available in .NET).
Collapse | Copy Code

ImportsSystem

A Class
Probably, you are already familiar with classes and objects. Simply speaking, a Class is a
definition of a real life object. For example, Human is a class for representing all human
beings. Dog is a class to represent all Dogs. Classes can contain functions too. Animals is
a namespace.
Collapse | Copy Code

NamespaceAnimals

WinForms Tab Control with


properly drawn bottom tabs
Advantage of using Interface
and Inheritance in VB.NET (OOP)
Classic Visual Basics end
marked a key change in
software development
Load more records in Asp.Net
Gridview on button click from
sql server table
Diving in OOP (Day 1) :
Polymorphism and
Inheritance(Early
Binding/Compile Time
Polymorphism)
Asynchronous Named Pipes
(Overlapped IO) with VB.NET
A Look At What's Wrong With
Objects
Some of the Anti Patterns
Refactoring - elixir of youth for
legacy VB code

Dog is a class in the namespace Animals:


Collapse | Copy Code

ClassDog

Why I Chose C++


Add a custom template to
Visual Studio .NET 2003

Bark is a function in this Class:


Collapse | Copy Code

A simple address book


application in Perl
Design Patterns, Explained - For
Beginners

FunctionBark()
Console.Writeline("Dogisbarking")
EndFunction
EndClass
EndNamespace

Play your AVI files with this


DirectX video player

An Object

Related Research

An object is an instance of a Class. For example, Jimmy is an object of type Dog. We will
create an object in the next section. Read on.

Modules
You can use modules to write common functions. A Module is a group of functions. Unlike
functions in classes, Public functions in modules can be called directly from anywhere
else. VB provides Functions and Subroutines. Functions and Subroutines are almost the
same, but the difference is that a subroutine can't return a value.

Enterprise Imaging on the Web:


A How To Guide for Developers

Collapse | Copy Code

PublicModulemodMain

Execution will start from the Main() subroutine:


Collapse | Copy Code

SubMain()
'Callourfunction.Seebelow
OurFunction()
Endsub

Custom API Management for


the Enterprise: Learn how to
build a successful API strategy

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

3 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

[Webinar]

OurFunction: Our own little function to use the class Dog:


Collapse | Copy Code

FunctionOurFunction()
'HereishowwedeclareavariableJimmyoftypeDog.
'WeuseAnimals.Dogbecause,theclassDogisinthe
'namespaceAnimals(seeabove).

DimJimmyasAnimals.Dog

'Createanobject.UnlikeinVB6,itisnotrequiredtouse
'the'set'keyword.

Jimmy=newAnimals.Dog()

'Anotherwaytocreateanobjectis
'DimJimmyasnewDog

'CallJimmy'sMainFunction
Jimmy.Bark()
EndFunction
Endmodule

Developer Tips for Scanning on


the Web

Insider Secrets on API Security


From Experts at Securosis
[Webinar]

The major access types are Public, Private, Friend and Protected. A Class may contain
functions, variables etc., which can be either Public or Private or Protected or Friend. If
they are Public, they can be accessed by creating objects of the Class. Private and
Protected members can be accessed only by the functions inside the Class. Protected
members are much like Private members, but they have some special use while inheriting a
Class. We will see this later, in Inheritance (Lesson 5). Friend members can be accessed only
by elements of the same project, and not by the ones outside the current project. Let us expand
our dog class.
Import the System namespace (already available in .NET).
Collapse | Copy Code

ImportsSystem

Animals is a namespace.
Collapse | Copy Code

NamespaceAnimals

Dog is a class in the namespace Animals.


Collapse | Copy Code

PublicClassDog
'Apublicvariable
PublicAgeOfDogasInteger

Bark is a function in this class. It is Public:


Collapse | Copy Code

PublicFunctionBark()
Console.Writeline("Dogisbarking")
EndFunction

Walk is a function in this class. It is Private.


Collapse | Copy Code

PrivateFunctionWalk()
Console.Writeline("Dogiswalking")
EndFunction
EndClass
EndNamespace

Our Module:
Collapse | Copy Code

PublicModulemodMain

Execution will start from the Main() subroutine:


Collapse | Copy Code

SubMain()
'Callourfunction.Seebelow

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

4 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

OurFunction()
Endsub
'OurFunction:CalledfromMain()
FunctionOurFunction()
DimJimmyasAnimals.Dog
Jimmy=newAnimals.Dog()
'Thiswillwork,becauseBark&Ageofdogarepublic
Jimmy.Bark
Jimmy.AgeOfDog=10
'CallingtheWalkfunctionwillnotworkhere,because
'Walk()isoutsidetheclassDog
'Sothisiswrong.Uncommentthisandtrytocompile,itwill
'causeanerror.
'Jimmy.Walk
EndFunction
EndModule

Encapsulation
Putting all the data and related functions in a Class is called Encapsulation.

Data Hiding or Abstraction:


Normally, in a Class, variables used to hold data (like the age of a dog) is declared as
Private. Functions or property routines are used to access these variables. Protecting the
data of an object from outside functions is called Abstraction or Data Hiding. This
prevents accidental modification of data by functions outside the class.

The shared members in a class (both functions and variables) can be used without creating
objects of a class as shown. The Shared modifier indicates that the method does not operate on
a specific instance of a type and may be invoked directly from a type rather than through a
particular instance of a type.
Import the System namespace (already available in .NET).
Collapse | Copy Code

ImportsSystem

Animals is a namespace.
Collapse | Copy Code

NamespaceAnimals

Dog is a class in the namespace Animals.


Collapse | Copy Code

ClassDog

Bark is a now a Public, shared function in this class.


Collapse | Copy Code

PublicSharedFunctionBark()
Console.Writeline("Dogisbarking")
EndFunction

Walk is a Public function in this class. It is not shared.


Collapse | Copy Code

PublicFunctionWalk()
Console.Writeline("Dogiswalking")
EndFunction
EndClass
EndNamespace

Our Module:
Collapse | Copy Code

PublicModulemodMain

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

5 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

Execution will start from the Main() subroutine.


Collapse | Copy Code

SubMain()
'WecancalltheBark()functiondirectly,
'withoutcreatinganobjectoftypeDog
'becauseitisshared.
Animals.Dog.Bark()
'WecancalltheWalk()functiononly
'aftercreatinganobject,because
'itisnotshared.
DimJimmyasAnimals.Dog
Jimmy=newAnimals.Dog()
Jimmy.Walk()
'NowGuess?TheWriteLine()functionweusedsofar
'isasharedfunctioninclassConsole:)
'Also,wecanwritetheMain()functionitselfasashared
'functioninaclass.i.eSharedSubMain().Try
'movingMain()fromthismoduletotheaboveclass
Endsub
EndModule

Overloading is a simple technique, to enable a single function name to accept parameters of


different type. Let us see a simple Adder class. Import the System namespace (already available
in .NET).
Collapse | Copy Code

ImportsSystem
ClassAdder

Here, we have two Add() functions. This one adds two integers. Convert.ToString is
equivalent to the good old CStr.
Collapse | Copy Code

OverloadsPublicSubAdd(AasInteger,BasInteger)
Console.Writeline("AddingIntegers:"+Convert.ToString(a+b))
EndSub

This one adds two strings.


Collapse | Copy Code

OverloadsPublicSubAdd(AasString,BasString)
Console.Writeline("AddingStrings:"+a+b)
EndSub
'Andbothhavethesamename.Thisispossiblebecause,weusedthe
'Overloadskeyword,tooverloadthem.
'Here,wehavetheMainFunctionwithinthisclass.Whenyouwrite.
'yourmainfunctioninsidetheclass,itshouldbeasharedfunction.
SharedSubMain()
DimAdderObjasAdder
'Createtheobject
AdderObj=newAdder
'Thiswillinvokefirstfunction
AdderObj.Add(10,20)
'Thiswillinvokesecondfunction
AdderObj.Add("hello","howareyou")
EndSub
EndClass

Inheritance is the property in which, a derived class acquires the attributes of its base class. In
simple terms, you can create or 'inherit' your own class (derived class), using an existing class
(base class). You can use the Inherits keyword for this.
Let us see a simple example. Import the System namespace (already available in .NET).
Collapse | Copy Code

ImportsSystem

Our simple base class:


Collapse | Copy Code

ClassHuman
'Thisissomethingthatallhumansdo

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

6 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

PublicSubWalk()
Console.Writeline("Walking")
EndSub
EndClass

Now, let us derive a class from Human.


A Programmer is a Human.
Collapse | Copy Code

ClassProgrammer
InheritsHuman
'WealreadyhavetheaboveWalk()function
'Thisissomethingthatallprogrammersdo;)
PublicSubStealCode()
Console.Writeline("Stealingcode")
EndSub
EndClass

Just a MainClass.
Collapse | Copy Code

ClassMainClass
'Ourmainfunction
SharedSubMain()
DimTomasProgrammer
Tom=newProgrammer

'Thiscallisokiebecauseprogrammergotthisfunction
'fromitsbaseclass
Tom.Walk()

'ThisisalsocorrectbecauseTomisaprogrammer
Tom.StealCode()
EndSub
EndClass

Additional Notes:
MustInherit
The MustInherit keyword specifies that a class cannot be instantiated and can be used
only as a base class. I.e., if you declare our Human class as "MustInheritClassHuman",
then you can't create objects of type Human without inheriting it.

NotInheritable
The NotInheritable keyword specifies that a class cannot be inherited. I.e., if you
specify 'NotInheritableClassHuman', no derived classes can be made from the
Human class.

By default, a derived class Inherits methods from its base class. If an inherited property or
method needs to behave differently in the derived class it can be overridden; that is, you can
define a new implementation of the method in the derived class. The Overridable keyword is
used to mark a function as overridable. The keyword Overrides is used to mark that a function
is overriding some base class function. Let us see an example.
Import the System namespace (already available in .NET).
Collapse | Copy Code

ImportsSystem

Our simple base class:


Collapse | Copy Code

ClassHuman
'Speak()isdeclaredOverridable
OverridablePublicSubSpeak()
Console.Writeline("Speaking")
EndSub
EndClass

Now, let us derive a class from Human:


An Indian is a Human:

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

7 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

Collapse | Copy Code

ClassIndian
InheritsHuman
'LetusmakeIndianspeakHindi,theNationalLanguage
'inIndia
'Speak()isoverridingSpeak()initsbaseclass(Human)
OverridesPublicSubSpeak()
Console.Writeline("SpeakingHindi")
'Important:Asyouexpect,anycalltoSpeak()insidethisclass
'willinvoketheSpeak()inthisclass.Ifyouneedto
'callSpeak()inbaseclass,youcanuseMyBasekeyword.
'Likethis
'Mybase.Speak()
EndSub
EndClass

Just a class to put our Main().


Collapse | Copy Code

ClassMainClass
'Ourmainfunction
SharedSubMain()
'TomisagenericHuman
DimTomasHuman
Tom=newHuman
'TonyisahumanandanIndian
DimTonyasIndian
Tony=newIndian
'ThiscallwillinvoketheSpeak()function
'inclassHuman
Tom.Speak()
'ThiscallwillinvoketheSpeak()function
'inclassIndian
Tony.Speak()
EndSub
EndClass

Polymorphism is the property in which a single object can take more than one form. For
example, if you have a base class named Human, an object of Human type can be used to hold an
object of any of its derived type. When you call a function in your object, the system will
automatically determine the type of the object to call the appropriate function. For example, let
us assume that you have a function named speak() in your base class. You derived a child class
from your base class and overloaded the function speak(). Then, you create a child class object
and assign it to a base class variable. Now, if you call the speak() function using the base class
variable, the speak() function defined in your child class will work. On the contrary, if you are
assigning an object of the base class to the base class variable, then the speak() function in the
base class will work. This is achieved through runtime type identification of objects. See the
example.
Import the System namespace (already available in .NET).
Collapse | Copy Code

ImportsSystem

This example is exactly the same as the one we saw in the previous lesson. The only difference is
in the SharedSubMain() in the class MainClass. So scroll down and see an example:
Our simple base class:
Collapse | Copy Code

ClassHuman
'Speak()isdeclaredOverridable
OverridablePublicSubSpeak()
Console.Writeline("Speaking")
EndSub
EndClass

Now, let us derive a class from Human.


An Indian is a Human.
Collapse | Copy Code

ClassIndian
InheritsHuman
'LetusmakeIndianspeakHindi,theNationalLanguage
'inIndia
'Speak()isoverridingSpeak()initsbaseclass(Human)

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

8 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

OverridesPublicSubSpeak()
Console.Writeline("SpeakingHindi")
'Important:Asyouexpect,anycalltoSpeak()insidethisclass
'willinvoketheSpeak()inthisclass.Ifyouneedto
'callSpeak()inbaseclass,youcanuseMyBasekeyword.
'Likethis
'Mybase.Speak()
EndSub
EndClass

Carefully examine the code in Main():


Collapse | Copy Code

ClassMainClass
'Ourmainfunction
SharedSubMain()
'LetusdefineTomasahuman(baseclass)
DimTomasHuman
'Now,IamassiginganIndian(derivedclass)
Tom=newIndian
'Theaboveassignmentislegal,because
'IndianIS_Ahuman.
'Now,letmecallSpeakas
Tom.Speak()
'WhichSpeak()willwork?TheSpeak()inIndian,orthe
'Speak()inhuman?
'Thequestionarisesbecause,TomisdeclaredasaHuman,
'butanobjectoftypeIndianisassignedtoTom.
'TheAnsweris,theSpeak()inIndianwillwork.Thisisbecause,
'mostobjectorientedlanguageslikeVb.netcanautomatically
'detectthetypeoftheobjectassignedtoabaseclassvariable.
'ThisiscalledPolymorphism
EndSub
EndClass

Import the System namespace (already available in .NET).


Collapse | Copy Code

ImportsSystem

A Constructor is a special function which is called automatically when a class is created. In


VB.NET, you should use useNew() to create constructors. Constructors can be overloaded (see
Lesson 4), but unlike the functions, the Overloads keyword is not required. A Destructor is a
special function which is called automatically when a class is destroyed. In VB.NET, you should
use useFinalize() routine to create Destructors. They are similar to Class_Initialize and
Class_Terminate in VB 6.0.

Dog is a class:
Collapse | Copy Code

ClassDog
'Theagevariable
PrivateAgeasinteger

The default constructor:


Collapse | Copy Code

PublicSubNew()
Console.Writeline("DogisCreatedWithAgeZero")
Age=0
EndSub

The parameterized constructor:


Collapse | Copy Code

PublicSubNew(valasInteger)
Console.Writeline("DogisCreatedWithAge"+Convert.ToString(val))
Age=val
EndSub

This is the destructor:


Collapse | Copy Code

OverridesProtectedSubFinalize()
Console.Writeline("DogisDestroyed")
EndSub
'TheMainFunction
SharedSubMain()

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

9 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

DimJimmy,JackyasDog
'Createtheobjects
'Thiswillcallthedefaultconstructor
Jimmy=newDog
'Thiswillcalltheparameterizedconstructor
Jacky=newDog(10)
EndSub
'TheDestructionwillbedoneautomatically,when
'theprogramends.ThisisdonebytheGarbage
'Collector.
EndClass

You can use both properties and fields to store information in an object. While fields are simply
Public variables, properties use property procedures to control how values are set or returned.
You can use the Get/Set keywords for getting/setting properties. See the following example.
Import the System namespace (already available in .NET).
Collapse | Copy Code

ImportsSystem

Dog is a class.
Collapse | Copy Code

PublicClassDog
'Aprivatevariabletoholdthevalue
PrivatemAgeOfDogasInteger

This is our property routine:


Collapse | Copy Code

PublicPropertyAge()AsInteger
'Calledwhensomeonetriestoretreivethevalue
Get
Console.Writeline("GettingProperty")
ReturnmAgeOfdog
EndGet
Set(ByValValueAsInteger)
'Calledwhensomeonetriestoassignavalue
Console.Writeline("SettingProperty")
mAgeOfDog=Value
EndSet
EndProperty
EndClass

Another class:
Collapse | Copy Code

ClassMainClass
'Ourmainfunction.Executionstartshere.
SharedSubMain()
'Letuscreateanobject.
DimJimmyasDog
Jimmy=newDog
'Wecan'taccessmAgeofDogdirectly,soweshould
'useAge()propertyroutine.
'Setit.TheAgeSetroutinewillwork
Jimmy.Age=30
'Getitback.TheAgeGEtroutinewillwork
DimcurAge=Jimmy.Age()
EndSub
EndClass

Let us analyze a simple program. First, let us import the required namespaces:
Collapse | Copy Code

ImportsSystem
ImportsSystem.ComponentModel
ImportsSystem.Windows.Forms
ImportsSystem.Drawing
'WeareinheritingaclassnamedSimpleForm,fromthe
'classSystem.Windows.Forms.Form
'
'i.e,Windowsisanamespaceinsystem,Formsisa
'namespaceinWindows,andFormisaclassinForms.
PublicClassSimpleForm

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

10 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

InheritsSystem.Windows.Forms.Form
'Ourconstructor
PublicSubNew()
'Thiswillinvoketheconstructorofthebase
'class
MyBase.New()

Set the text property of this class. We inherited this property from the base class:
Collapse | Copy Code

Me.Text="Hello,HowAreYou?"
EndSub
EndClass
Collapse | Copy Code

PublicClassMainClass
SharedSubMain()
'CreateanobjectfromourSimpleFormclass
DimsfasSimpleForm
sf=newSimpleForm

'PassthisobjecttotheRun()functiontostart
System.Windows.Forms.Application.Run(sf)
EndSub
EndClass

That is it. Now you can atleast read and understand most of those VB.NET source code, and
probably implement more OOP features in your VB.NET programs. Now, in my next article, I'll try
to cover the patterns and practices in VB.NET.

Nov 13th, 2004


Prepared this article for publishing.

This article has no explicit license attached to it but may contain usage terms in the article text or
the download files themselves. If in doubt please contact the author via the discussion board
below.
A list of licenses authors might use can be found here

Anoop
Madhusudanan
Architect
India

Architect, Developer, Speaker | Wannabe GUT inventor & Data Scientist | Microsoft MVP in C# |
Tweets on JS, Mobile, C#, .NET, Cloud, Hadoop | Seeker.
Follow: I'm In Twitter @amazedsaint | Blog: http://amazedsaint.com
BigData for .NET Developers Using Azure & Hadoop
Hack Raspberry Pi to Build Apps In C#, Winforms and ASP.NET
Changing Times For Web Developers - Responsive Design and 6 Tips You Need To Survive
7 Freely Available Ebooks For .NET developers
5 Back to Basics C# Articles - Fluent Interfaces, Expr Trees etc

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

11 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

3 Gems from Mono to spice up your .NET Apps


Top 5 Common Mistakes .NET Developers Must Avoid
6 Cool VS2010 Tips you may find interesting
4 .NET 4.0 Libraries you *should* know about

Follow on

Twitter

Article Top

You must Sign In to use this message board.


Search this forum
Profile popups

Spacing Relaxed

Noise Medium

Layout Open All

Go
Per page 50

Update

First Prev Next

Very nice, suggestion!

bluesathish

6-Dec-13 4:18

Thanks for this really excellent article, can you explain other oops concept like types of
inheritance, data hiding etc with examples in Version2. My vote 5!
Sign In View Thread Permalink

Thanks,great help [modified]

theexplorerneverstop

6-Jun-13 23:32

Thanks for the information.You help me a lot in understanding OOP fundamentals.Your


article is clear and concise
modified 7-Jun-13 5:40am.

Sign In View Thread Permalink

my 5+++ [modified]

ssd_coolguy

5-Sep-12 23:52

It's really helpful article for everyone..


thanx Anoop...
ssd_coolguy

modified 6-Sep-12 6:03am.

Sign In View Thread Permalink

Excellent

Agyemang

14-Aug-12 22:22

Am always overwhelm when i found people writing good articles like this.
Great programmers out there. I need someone to help me with a code that will select
auto primary key from parent table and automatically insert it into child table as a foreign
key using vb.net and sql 2008

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

12 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

Sign In View Thread Permalink

My vote of 5

Agyemang

14-Aug-12 22:05

i have always find it difficult to understand object and class in vb.net but this article has
been a blessing to me
Sign In View Thread Permalink

My vote of 5

5-Jul-12 15:49

IBAAB

Explanations are clear with very easy to understand examples. Well done. Perfect for both
experts and newbies as well. Thanks
Sign In View Thread Permalink

Thank you

4-Jul-12 22:49

nethelp11

Great tutorial with great simple example given! Thank you!


Sign In View Thread Permalink

Thank you 5 *****r

Ash Shafiee

26-Apr-12 2:44

Ash Shafiee

26-Apr-12 2:44

adeel1981

17-Mar-12 2:25

Sign In View Thread Permalink

Thank you 5 *****

Sign In View Thread Permalink

Excellent

I am just loving this site.Almost everything which I need,I am able to find here
Always believe in God and never let misfortunes make you give up
Sign In View Thread Permalink

cool

lukman-cp

1-Mar-12 15:10

Member 8649884

16-Feb-12 8:37

Cool, tks for this tutorial


Sign In View Thread Permalink

Congrats!!!

For your great talent to transfer knowledge to others.


Sign In View Thread Permalink

Thank you

jkjerome

18-Aug-11 6:09

Thanks for a great and concise refresher on the basics. Nice work.
Sign In View Thread Permalink

My vote of 5

Saumitra Kumar Paul

15-Jul-11 10:50

great and cool

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

13 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

Sign In View Thread Permalink

Greate Job!!!

chirag.khatsuriya

30-May-11 16:02

dranko

28-May-11 22:03

Very good Article to understand OOPS.


Thanks...
Sign In View Thread Permalink

Great job.

Very simple and clear, with good examples. Great job.


Sign In View Thread Permalink

Superb

Member 2905526

2-May-11 19:41

Superb Anoop.. Very good and informative post.


Sign In View Thread Permalink

Thanks

Member 3863368

14-Jan-11 0:18

Member 3863368

14-Jan-11 0:17

Member 1725085

6-Jan-11 5:56

thank you very much


helpful article
we wait for more
Sign In View Thread Permalink

My vote of 5
thank you very much
helpful article
we wait for more
Sign In View Thread Permalink

Thanks!
Nice clear examples- very helpful to me
Sign In View Thread Permalink

My vote of 4

Vishal.Waman

4-Jan-11 19:22

Hayk Aleksanyan

7-Aug-10 0:00

victorpaul123

7-Jul-10 23:57

It was useful
Sign In View Thread Permalink

My vote of 3
examples are rather trivial
Sign In View Thread Permalink

My vote of 4
good job...
Sign In View Thread Permalink

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

14 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

Thankyou, great help !

highcopic

30-May-10 13:45

Thanks, your explanation cleared my brain! I jumped into VB.net to quick, from VBA, and
couldnt grasp the concepts.There is a lot of tutorials on writing the basic code, but they
dont describe it in the way you have, thanks again,
T
Sign In View Thread Permalink

vb.net

amhla

very easy to follow ....

1-Apr-10 1:10

thanx

Sign In View Thread Permalink

form

Manju Gowda

29-Mar-10 0:34

Hi,
How do i use multiple dynamic forms and controls in vb.net.

manju gowda
banglaore.
Sign In View Thread Permalink

Thanks

Manju Gowda

29-Mar-10 0:32

Very easy to understand the oops concep.


thanks agian.
Manju Gowda
Bangalore.
Sign In View Thread Permalink

Thank's ......
Thanks Alot

Member 4057475

14-Mar-09 11:40

now I understand it that was very nice and easy 5 / 5

Sign In View Thread Permalink

OOP in vb.net (database)

tornado12

8-Feb-09 14:20

Hi every one
I have lot difficulties in OOP in vb.net when I wan to use classes to connect my
application
to data base and if you can help me I wan a sample application (Add,delete,modify).
Please I need help I have an exam in OOP but the problem is that I dont have any idea
about
OOP when we use database
Sign In View Thread Permalink

It is very useful

2.38/5 (8 votes)

hafizes

6-Nov-08 7:57

Thanks
Sign In View Thread Permalink

[Message Removed]

1.00/5 (1 vote)

hankjmatt

13-Oct-08 21:10

Spam message removed

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

15 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

Sign In View Thread Permalink

Nice Article

1.00/5 (1 vote)

naman

28-May-08 0:53

Nice article. you have cleared all the difficult topics in a proper go & proper explanation
is there in the same regard
Thanks

NaMaN

Sign In View Thread Permalink

Thanks

jomet

2-Mar-08 20:38

suzmonster

14-Dec-07 5:08

nice article!!!

Sign In View Thread Permalink

Need a Programming Refresher?


Read This Article!

I've been away from programming for a couple years. I'm only halfway through this
article and must say it is EXACTLY what I needed. I wish I would have found this article
two months ago. I'm currently refactoring a VB6 program over to .NET in Visual Studio
2005. I understand OOP, SQL, and RDBMS but I had lost touch with the "lingo" of exactly
what is what in a program. Thank you for breaking .NET down for me so I can quickly get
back up to speed!
Sign In View Thread Permalink

nice one mate

1.00/5 (1 vote)

waqas rafi

5-Oct-07 16:10

well iam new to the vb world and find it really interesting and in short span we can grasp
many things from this contribution.....
cheers

no matter what
JUST KEEP IT REAL!

Sign In View Thread Permalink

nice one mate

waqas rafi

5-Oct-07 16:09

well iam new to the vb world and find it really interesting and in short span we can grasp
many things from this contribution.....
cheers
no matter what
JUST KEEP IT REAL!

Sign In View Thread Permalink

Hey....you rocks...nice job

theGreco

21-Sep-07 5:39

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

16 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

this have been the best way to explain about oop to anybody...congratulations.

Sign In View Thread Permalink

how can I test the code??

Sahar Diab

31-May-07 5:25

hi oop>>>
I wondered if u can help me in testing the code and give me the steps to test the class....
I am new in vb.net and in dealing with dll files
any help appretiated....
thx ,

Sahar
Sign In View Thread Permalink

Thanks!

2.00/5 (1 vote)

turtle1010

9-Feb-07 22:53

Thank you so much for the lessons, they are extremly simply written but up to the point

Sign In View Thread Permalink

For a fresher...... it's the best.

Manuuuuu

19-Dec-06 7:34

Simple and understanding words and memorable samples....good, Best of luck and
moreover thanks.
Viju
Sign In View Thread Permalink

very simple but very informative

2.00/5 (1 vote)

percyvimal

19-Dec-06 3:04

Very simple article but very informative and covers lot of hard to understand features in a
very simpler easily understandable way.
Expect more such nice articles
Regards

Help in need is the help indeed

Sign In View Thread Permalink

Thank You...

Woofs

15-Sep-06 10:04

Thank you for the article. I found it to be very clear and concise. Perfect examples.
Sign In View Thread Permalink

Great Contribution!!

5.00/5 (1 vote)

Raish

9-Aug-06 21:59

I think this article tells a lot of than a book of 1,000 pages related to OOP.
Specially lesson related to Polymorphism is excellent.
Md R Islam

Sign In View Thread Permalink

5.00/5 (1 vote)

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

17 of 18

sit back and enjoy

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

f2

20-May-06 20:46

http://download.microsoft.com/download/6/2/4/6247616D-A0C7-4552B622-3F0450DE2462/06VB1.wmv
from,
-= aLbert =-

Sign In View Thread Permalink

The Walk() function is inside the


class Dog

MickYL

12-Apr-06 20:30

Sub Main()
'Call our function. See below
OurFunction()
End sub

Really great Article. Just wanted to say I think the Walk() function is declared a private
function within the Class Dog. How do you use such a private member ? Really learnt a
lot on through this article. Thanks.
'OurFunction: Called from Main()
Function OurFunction()
Dim Jimmy as Animals.Dog
Jimmy=new Animals.Dog()
'This will work, because Bark & Ageofdog are public
Jimmy.Bark
Jimmy.AgeOfDog=10
'Calling the Walk function will not work here, because
'Walk() is outside the class Dog
'So this is wrong. Uncomment this and try to compile, it will
'cause an error.
'Jimmy.Walk
End Function
End Module
Sign In View Thread Permalink

OO Programming concepts VB.NET

1.80/5 (2 votes)

Integrale EVO2

28-Mar-06 15:09

Many thanks, at last I see the light. I've been struggling for weeks with various articles
and pages from books trying to put together some basic no frills document to try to have
definitions and a reference for these concepts.
This was and is a fantastic artical for beginners. Straight and to the point. .NET is now not
so much of a mystery.
Again many thanks.
Will NZ
Sign In View Thread Permalink

Nicely done

1.75/5 (5 votes)

GlimmerMan

21-Mar-06 10:57

One of the things I enjoy doing is writing very easy to understand tutorials as you have
done here, nicely done and simple as it should be.;)
Kevin S. Gallagher
Programming is an art form that fights back
Sign In View Thread Permalink

2.33/5 (2 votes)

6/3/2014 11:30 AM

Object Oriented Programming In VB.NET - CodeProject

18 of 18

http://www.codeproject.com/Articles/8825/Object-Oriented-Programm...

French Translation

9-Nov-05 21:00

Xoh

With the kind authorization of his author, this article has been translated in french. You
can read it here : http://xo.developpez.com/tutoriel/vb.net/poo/
Thanks Anoop
__
Xo
-- modified at 17:32 Sunday 13th November, 2005
Sign In View Thread Permalink

Last Visit: 31-Dec-99 18:00


General

News

Permalink | Advertise | Privacy | Mobile


Web04 | 2.8.140526.1 | Last Updated 19 Nov 2004

1.83/5 (3 votes)

Last Update: 2-Jun-14 14:30


Suggestion

Question

Refresh
Bug

Layout: fixed | fluid

Answer

Joke

Rant

1
Admin

Article Copyright 2004 by Anoop Madhusudanan


Everything else Copyright CodeProject, 1999-2014
Terms of Service

6/3/2014 11:30 AM

Вам также может понравиться