KEMBAR78
VB.net
VB.net
Introduction
 Visual Basic .NET (VB.NET) is an object-
oriented computer programming language
implemented on the .NET Framework.
 Everything in VB.NET is an object, including
all of the primitive types (Short, Integer,
Long, String, Boolean, etc.) and user-
defined types, events, and even
assemblies.
 All objects inherits from the base class
Object
Strong Programming Features
VB.Net
 Boolean Conditions
 Automatic Garbage Collection
 Standard Library
 Assembly Versioning
 Properties and Events
 Delegates and Events Management
 Easy-to-use Generics
 Indexers
 Conditional Compilation
 Simple Multithreading
Data Types Available in VB.Net
Data Type Storage Allocation Value Range
Boolean Depends on implementing platform True or False
Byte 1 byte 0 through 255 (unsigned)
Char 2 bytes 0 through 65535 (unsigned)
Date 8 bytes
0:00:00 (midnight) on January 1, 0001
through 11:59:59 PM on December 31,
9999
Decimal 16 bytes
0 through +/-
79,228,162,514,264,337,593,543,950,335
(+/-7.9...E+28) with no decimal point; 0
through +/-
7.9228162514264337593543950335 with
28 places to the right of the decimal
Double 8 bytes
-1.79769313486231570E+308 through -
4.94065645841246544E-324, for negative
values 4.94065645841246544E-324
through 1.79769313486231570E+308, for
positive values
Integer 4 bytes
-2,147,483,648 through 2,147,483,647
(signed)
Long 8 bytes
-9,223,372,036,854,775,808 through
9,223,372,036,854,775,807(signed)
Object
4 bytes on 32-bit platform 8 bytes
on 64-bit platform
Any type can be stored in a variable of
type Object
SByte 1 byte -128 through 127 (signed)
Short 2 bytes -32,768 through 32,767 (signed)
Single 4 bytes
-3.4028235E+38 through -1.401298E-45
for negative values; 1.401298E-45 through
3.4028235E+38 for positive values
String Depends on implementing platform
0 to approximately 2 billion Unicode
characters
UInteger 4 bytes 0 through 4,294,967,295 (unsigned)
ULong 8 bytes
0 through 18,446,744,073,709,551,615
(unsigned)
User-
Defined
Depends on implementing platform
Each member of the structure has a range
determined by its data type and
independent of the ranges of the other
members
UShort 2 bytes 0 through 65,535 (unsigned)
Data Types Default Value Size (bytes)
Char 0 2
Byte 0 1
Short 0 2
Integer 0 4
Long 0 8
Single 0.0 4
Double 0.0 8
Decimal 0.0 16
Boolean False 1
Date 1/1/0001 12:00:00 Am 8
Operators
Arithmetic +,-,*,/,^,,Mod
Relational =,<>,<,>,<=,>=
Logical And, or, not
Assignment =,+=,-=,/=,*=
Option Statements
 Option explicit on/off
 Option compare binary/text
 Option strict on/off
Option explicit on/off
 If option explicit on variable
declaration is compulsory.
 If it is off variable declaration is not
compulsory.
 By default it is on.
Option compare binary/text
 By default binary
 If option compare is binary
comparison is case sensitive.
Option strict on/off
 By default option strict is off
Conditional Statement
If condition then
End if
If condition then
else
End ifIf condition then
Else if condition then
End if
 Iif(expression, true, false)
Short circuit evaluation
 Andalso, orelse
 VB.NET also provide two logical operators
andalso, orelse that can be used to help
evaluate expression as efficiently as possible.
 The andalso operator is used to prohibit the
evaluation of second condition if the result of
the expression is known after evaluating the
1st operand.
 There is a similar case with the orelse
operator in this case if the 1st condition is true
then 2nd condition will not be evaluated and
operator return true.
Select case
 Select case variablename
 Case 1
 Case 2
 Case else
 End select
Looping statements
 Do……..loop
 While………end while
 For………..next
 For each………….next
Exit statement
 Exit for
 Exit do
 Exit while
Procedure and function in VB.NET
 Procedure and functions are block of code in
a program. They are also termed as
subprogram and are basically used to avoid
repetition of same code a number of times.
 By making use if procedures and functions
we save time there by making development
faster.
 Functions are almost similar to
subprocedure except that function can
return value to the calling procedure.
Function procedures re encloses
between function and end function
block. Function returns a value
whereas procedure does not return a
value.
Passing arguments to function and
procedures
 Call by value
 Call by reference
Call by value
 It is used to pass and argument by value.
 It indicated that the value of the variable
should not be modified by the call procedure
or function.
 Hence when a variable is passed using
byval keyword a copy of the variable is
created within the call procedure. Any
change made to the value of the variable will
affect the copy not the variable itself.
Call by reference
 It is used to indicate that the arguments are
passed Byreference not value. This means
that the call procedure can modify or change
the variable. By passing argument by
reference a procedure is given access to the
original value of the variable in its memory
location. As a result any changes made to
the argument within the call function will be
reflected in the calling procedure.
Access Specifier
 Private, Public
 By default it is private
 When declare with a public keyword
elements are available throughout the
current project and within a other project that
are referencing the current project.
 On the other hand if elements are declare as
private it can only used within the current
module.
Arrays , Enumeration and
structure
 Array is an entity that contains multiple variables of
the same data type.
 This variables are referred to by a single name.
 This variables are called as elements of an array.
 An array subscripts or index is used to access each
element of an array.
 Array in VB.NET are classified into single and multi
dimensional array.
 Length property gives the total number of elements
in an array.
Redim statement
 The redim keyword in VB.NET allows us to
change the size of array after they have been
declared.
 A redim statement can only be used within a
procedure and not at the module level.
 When the size of an array is modified using
Redim keyword the original contents of an
array is lost, however the contents can be
retain using the keyword Preserve with
Redim.
Multidimentional Arrays
 Rectangular Arrays – Rectangular arrays are
multidimetional arrays where the number of
elements in each row is same, which occupy
adjacent memory locations.
 Jagged Arrays – A jagged array is an array of
arrays. When we declare a jagged array, we
specify number of rows. Each row holds an
array, which can be of different length.
Enumeration
 Enumeration are used when we need
to refer the values of primitive types
such as byte, short, integer as
constants
Structure
 A structure is a composite user defined
datatype using which we can group data of
different data type together.
 A structure can be declared with in a module
but it cannot appear inside a procedure.
 A Statement can contain data members as
well as procedure and functions.
 The scope of the data members within a
structure is public.
Object oriented concepts in
VB.NET
 Abstraction
 Encapsulation
 Polymorphism
 Data Hiding
 Inheritance
Class
 A class is a representation or a template of
common attributes of behavior of objects.
 The content of a class are called members.
Based on a class instance are created which
are called objects.
Properties and Methods
 In VB.NET data members that describes as
an object are called fields or properties.
 The members which describes object
behavior are called methods.

Properties
 Properties are an extension of variables.
 They don’t denote storage location but
instead have accessor which specify
statements that can be executed to assign or
retrieve to or from the properties.
 A set accessor in a property declaration is
used to assign values.
 A get accessor is used to retrieve values of
the property.
Types of properties
 Write only properties – It must have set
accessor and Get accessor may be omitted
 Read only – It must have Get accessor, the
Set accessor may be omitted.
 Read / Write – This type of property must
have Get as well as Set accessor.
Constructor
 Constructor executes automatically every
time when an object is created.
 Constructors are typically declared public
and are used for initialised purpose.
 In VB.NET the lifetime of an object begins
when it is created with the New keyword.
 Constructor in VB.NET are written using sub
new()…. End sub
Destructor
 The lifetime of an object ends when it is
destroy or goes out of the scope.
 In VB.NET the destructors are written using
the finalize() method.
 Destructor are use for cleanup operations
such as releasing of memory that is no
longer required.
Method Overloading
 Overloading is the process of declaring the
methods of a class having same name but
different signature.
 The signature of the method comprises the
number and the types of arguments.
 In VB.NET functions, procedures,
constructors and properties can be
overloaded.
Inheritance in VB.NET
 It is a process of creating classed
based on existing classes.
 Inheritance is based on the principle of
code reuse.
Access Specifiers
 Public – All public elements of a class are
inherited by it’s derived classes.
 Private – Private elements of a class can’t be
inherited by derived classes.
 Protected – Protected access for elements
denote that elements may be used within the
derived class but not outside the derived
class.
 Friend – Friend access modifier is
used to denote that the elements
accessible throughout the program in
which the class is defined.
 Protected Friend – This access
modifier indicated that the elements
contain features of both protected and
friend modiers.
Abstract Class
 An abstract class can’t be used to create
objects.
 It is generally used as as template to derive
other classes. An abstract class typically
has abstract methods which are only
method declaration without any
implementation.
 In VB.NET all classes are inheritable.
 The mustinherit keyword makes the base
class as a abstract class
Final Classes
 Final classes in VB.Net are marked
with the notinheritable keyword.
 Final classes can’t have derive
classes but they can be use to create
objects.
Method overriding
 Overriding is the process of overriding the methods
or properties of a base class in a derived class.
 In case of method overriding the return type, name
and arguments of method in the derived class must
be the same as that of the method be overriden.
 When an object of derived class invokes the
overriden method it will be derive class
implementation that will be called.
 The base class method must be marked with
keyword overridable and derived class method
marked with keyword overrides.
Shadows keyword
 If we wish to hide the inherited method within
a derive class and invoke an overriden
version of the method then we use the
shadows keyword.
 Shadows keyword can’t be used with the
overloads keyword.
Mybase keyword
 Mybase keyword is used to refer to the base
class method in derived class, that has
overriden method of the base class.
Myclass keyword
 This keyword works opposite to the way in
which mybase keyword works.
 Assume that a base method is overriden in
derived class.
 If the object that is used to invoke the method
is of derived class then it is always the
derived class version of the method in
another method of the base class.
 Instead of derived class version we must use
myclass keyword.
Interfaces , Namespaces
 Interfaces are similar to classes except that they
have no implementation methods. Methods are
only declare within within an interface and don’t
contain any code.
 An interface can’t be instantiated it is typically
implemented be a class using implements keyword.
 An interface defines using
 Interface <interfacename>
 End interface
 A class can’t inherit from two other
classes but it can inherit a class and
implement an interface.
 Multiple inheritance is not supported in
VB.NET.
 However, it can be achieved with the
help of inherfaces.
Namespaces
 In VB.NET clas libraries are comprises of
namespaces.
 Namespaces are used to organise nested
entities such as other namespaces, classes,
interfaces and so on.
 Namespaces takes care of the way in which
program elements are expose to other
program with the help of various access
modifiers.
 Modules and classes are generally put inside
namespaces.
Collections
 A collection is term used to describe a means
of grouping and managing related entities.
 An VB.NET a collection is used to manage
the objects that are used to manage the
objects that are used by class.
 The simplest way to create a public instance
of type microsoft.visualbasic.collection in the
program.
Events
 Events are actions that have trigger either by
a user action, program logic or by the
system.
 Whenever an event occurs the user may
either ignore an event or deal with the event
with the help of suitable code.
 Procedure containing codes that will process
the events are called event handler.
 The syntax to create an event is :-
 Private/public/proceted event
eventname(argument list)
 Once declare an event can be activated with
the help of the raise event statement placed
inside a subprocedure.
 To process an event we may use any one of
the following approaches :-
◦ Use addhandler statement to provide a reference
to an event handler.
◦ Use withevents, with conjunction, withhandles
keywords.
Delegates
 Representative
 Pointer to function.
 In VB.NET a delegate is define as
representative of a function or a procedure it
holds a reference to a method.
 A delegate declaration must specify the
parameter or return type for the method
which it represents.
 VB.NET allows us to create two types of
delegate classes.
 Singlecast delegates
 Multicast delegates
 Single cast delegates are delegate classes
that are derived from delegate class.
 Multicast delegates are derived from
multicast delegate class.
 Single cast delegates contains an invocation
list with only method where as multicast
delegate contains invocation list with one or
more methods.
Multithreading
 Multithreading in VB.NET is accomplish
through the classes and interfaces in the
system.threading namespace.
 To create a new thread we pass a delegate
to the constructor of the system.threading
thread class.
 This delegate must point to a method that will
act as starting point for the thread.
Name property
 A thread can be given a name by
using name property of the thread
class.
Suspend and resume method
 The suspend and resume method of
system.threading thread class is used to
suspend an action of the thread for
indefined period.
 The thread can be resume using the
resume method.
Synchronisation
 When two or more threads in a multithreaded
application access common method or data
simultaneously there will be a conflict and as a
result important info could be lost or data will
become inconsistent.
 To avoid this it is necessary to have some kind of
mechanism in a multithreaded application that
allows methods or data to be access by one thread
at a time.
 Synchronisation is a process that allows thread to
access methods or data one thread at a time.
 We use Synclock keyword for it.
 The synclock ………. End synclock block
encloses the statement that are likely to
cost conflict in data and act as monitor thus
giving the calling thread exclusive lock.
 Because of this only one thread is given
priority to execute at any given time.
Monitor Class
 VB.NET provides a monitor class which
defines enter, try enter and exit methods.
 These methods of monitor class describe
below.
 Enter method :- This method acquires a
monitor lock for an object. This method may
block execution of other methods in the
current thread holds the lock.
 Try Enter :- Tries to acquire a monitor lock
without blocking.
 Exit :- This method release the monitor lock
on an object.
 Wait :- Wait method waits until another
thread passes notification method using the
PULSE method.
 Pulse :- Pulse method is used to notify
about the change in the state of an object to
a thread that is waiting.
Memory management in VB.NET
 In an automatic memory management
environment a garbage collector program
runs as a separate thread.
 The garbage collector frees memory that no
longer needed.
 VB.NET uses a garbage collector to
implement automatic memory management.
Garbage collector
 The garbage collector needs to know when objects
are no longer in use by an application.
 This information is given to the garbage collector
using concept called metadata.
 Every element in a VB.NET includes metadata that
describe it.
 By means of metadata the CLR knows the layout of
each object in memory.
 The JIT compiler and the CLR maintains a list of
active rules.
 This is then made accessible to the garbage
collector algorithm.
Dialog Boxes
 Modal – Open, Save, print
 Modeless – Find, replace.
Common Dialog Boxes
 Openfile
 Savefile
 Font
 Color
 Print dialog
 Print preview
 Pagesetup
 A dialogbox is a temporary window that
contain controls that can be used to display
information and messages to the user or to
accept the user input so that a specific
action can be carried out.
Types of Dialog Boxes
 Modal – A modal dialog box forces the user
to make a selection or perform a particular
action before proceeding with an application.
 For eg. If a modal dialog box is used to
display a message the user will not able to
switch another form unless and until the user
closes the dialog box.
 Modeless :- This dialog boxes let the user
switch to another form without having to
close the dialog box.
 Modeless dialog box allow user to continue
to work anywhere in the current application
while the dialog box is displayed.
Error handling in VB.NET
 Data Validation :- An application processes
information that user entered. Data validation
ensures that the data entered in the
application is accurate and of valid data type.
In winforms two data validation techniques
are supported
 A field level validation
 A form level validation
Field level validation
 Data in the field of the form are verified one at
a time after the user enters a value into a
particular field and moves on to the next field
on the form.
 Controls also support some methods and
events that are useful for verification and
validation data.
 Leave event :- When a form or a control
looses the focus or the cursor leaves the
control, the leave event is fire.
 Enter event :- This event is fire when the focus is
set to a field. This event can be used to check
whether the value entered in the previous field is
valid or not.
 Validating :- This event occurs when the control is
being validated. This event takes an argument of
type
◦ Cancelevent args
◦ The main property of the cancelevent args argument is the
cancel property.
◦ The cancel property can be set true or false to indicate
whether the event has to be canceled or not.
 Validated :- This event occurs after the validation of
the control is completed or after the validating event
is completed.
Keyboard events
 The main three keyboard events used in
validation are keypress, keydown, keyup
 A keypress event occurs when a keyboard
key is pressed while a control has focused.
The keypress event takes an argument of
type KeyPressEventArgs which represents
the character is composed when a key is
pressed.
Properties of keypresseventargs
 Handled – The value of this property indicates
whether the keypress event was handled or not.
 Keychar – This property represents the character
that correspond to the key press by the user.
 Key down/ Key up – These events are closely
related with the keypress events. The keydown
event occurs before keypress event as soon as the
user press a key and the keyup event occurs when
the user releases the key. The key down and keyup
events of types system.windows.forms.keyevent
args
Properties of keyeventargs
 Alt – It indicates whether the ALT key was
press or not.
 Control – It indicates whether ctrl key was
press or not.
 Shift - It indicates whether shift key was press
or not.
 Handled –
 Keycode – It will return keyboard code of the
key which when press triggers the keydown
and keyup events.
Exception Handling
 Exceptions are used to handle
abnormal/exceptional conditions that arises
while executing programs.
 Winforms include default exception that are
raised when an error occurs.
 Exceptions are used to handle runtime
errors.
 There are two different types of exception
classes supported in winforms,
System.exception and application.exception.
MDI
 Multiple Document interface
 A mdi application is made up of one MDI
parent form and one more child form.
 A MDI form is created in the same way as
we create a form, when the property
ISMDICONTAINER is set to true for a
window form it becomes a MDI form.
Collections Classes
 .NET provides the system.collections
namespace that contains various interfaces
and classes representing the collection of
objects. The advantage of using collection
classes :-
◦ Performance – Collection classes consist of
efficient algorithm.
◦ Similarity – Similar operation work on dissimilar
data types.
◦ Extensibility – We can extend the functionality of
collection classes for any new data type.
Collection Types
 Ordered collection
 Indexed collection
 Key collections
Ordered collection
 Classes that implement the I collection
interface fall under this category.
 In this category the insertion and deletion of
objects is order based i.e. the order in which
the elements are inserted controls, the order
in which they would be retrieve from the
collection. E.g. Stack Queue.
Indexed Collection
 Here the insertion and retrieval of elements
is index based i.e. elements can be retrieve
using O base numeric index.
 Such collections implement the I list
interface i.e. array, arraylist.
Key collections
 Here elements can be inserted and
retrieve using an associated key value
pairs.
 This classes implements the I
dictionary interface i.e. hashtable ,
sorted list.
Stack
 The collection namespace provides a stack
class, which provides Last In First Out way
to store and retrieve the elements.
 The operation by which an element is added
to the stack is called PUSH, and the
operation by which element is removed from
the stack is called POP.
 The member of the stack that refers last
element of the stack is called TOP.
Queue
 The collection namespace also provides a
queue class which provides First In First Out
way to store and retrieve the elements.
 The end at which first element is placed is
called front and the end at which last element
is placed is called rear.
 A new element get’s added at the end that is
at rear end and an element get removed from
front end.
Array List
 Array list class is similar to the array
class except that it’s size can grow
dynamically.
Hash table
 One of the most efficient known data
structure for fast look up is “HASH TABLE”.
 In a hash table we can store pair of values
and associated keys.
 The value are organised on the basis of the
keys.
 The keys can be used to retrieve the
corresponding values from the hash table.
GDI+
 .NET provides a set of GDI classes. This
classes allows programmers to draw
graphics or text without being require to
bother about the specification of the video
hardware.
 These classes are present in system.drawing
and system.drawing.drawing2D namespace.
 The GDI+ classes offer device independence
to our program.
 Device independence means that the same
program should work with the different
screens , keyboards and printers without
modifying the program.
 The GDI+ classes takes care of the
differences in hardware allowing a
programmer to concentrate on drawing.
Paint Handler
 The graphics class is a wrapper around the device
context.
 All methods used for drawing operations are
belongs to this class.
 This class is present in the system.drawing
namespace.
 When the onpaint eventhandler is called a
reference to the painteventargs object is passed to
it.
 The painteventargs class contains a property
access returns a reference to the graphics object.
FILE I/O
 We deal with files mainly for three purposes
getting properties of a file, reading and
writing data of primitive data types and
reading and writing data of user defined
types. For these purposes .NET provides
separate set of classes.
 The filesysteminfo and file classes are used
for performing file operations like creating ,
copying m deleting and moving of files.
 They also provide functions for getting
information of a file.
 The fileinfo and directoryinfo classes are
derived from the filesysteminfo class.
 Fileinfo class is used to perform an the file
operations that we can perform using the file
class.
 The DirectoryInfo class is used for creating ,
moving through directories and
subdirectories.
 The classes derived from the marshal Byref
object class are used for marshelling the
object across the application.
 Marshelling means creating an object in one
application and passing it’s state to another
application.
MarshalByRefObject
TextReader Stream Text Writer
String
Reader
Stream
Reader
String
Writer
String
Writer
 A stream is a sequence of bytes traveling
from source to destination or traveling over a
communication link.
 Two basic types of streams are InputStream
and OutputStream.
 An InputStream is used for read operation
while outputstream is used for write
operation.
 The streamReader class inherits a
textReader that reads characters from a
bytestream.
 The streamwriter clas inherits a textwriter for
writing a character to a stream.
Assembly
 Assemblies are building blocks of .NET application.
 Components are package into assemblies.
 Assembly can either be in a form of exe or dll files.
 To create the assembly.
 Programs->Ms visual studio 2005 -> Visual studio
tools -> Visual studio 2005 command prompt.
 Go to your application
 Vbc/t : library module1.dll
Inheritance Picker
 We can create a new form which is inherited
from another form.
 The environment has something called
‘inheritance picker’ that provides that
functionality.
 It is possible to create a base form with logic
and visual elements needed by all forms and
then have other forms inherits to get that
functionality.
 The logic and visual elements are
encapsulated in one location so that
changing the base form causes all the forms
inheriting form it to change automatically.
 This concept is called as ‘inheritance picker’.
 A form must be compiled in to an executable
file with the built command before it can be
used by the inheritance picker.
 Once that is done the menu options/ project/
add new item/inherited form allows the
addition of a form that inherits from another
form in the project.

VB.net

  • 1.
  • 2.
    Introduction  Visual Basic.NET (VB.NET) is an object- oriented computer programming language implemented on the .NET Framework.  Everything in VB.NET is an object, including all of the primitive types (Short, Integer, Long, String, Boolean, etc.) and user- defined types, events, and even assemblies.  All objects inherits from the base class Object
  • 3.
    Strong Programming Features VB.Net Boolean Conditions  Automatic Garbage Collection  Standard Library  Assembly Versioning  Properties and Events  Delegates and Events Management  Easy-to-use Generics  Indexers  Conditional Compilation  Simple Multithreading
  • 4.
    Data Types Availablein VB.Net Data Type Storage Allocation Value Range Boolean Depends on implementing platform True or False Byte 1 byte 0 through 255 (unsigned) Char 2 bytes 0 through 65535 (unsigned) Date 8 bytes 0:00:00 (midnight) on January 1, 0001 through 11:59:59 PM on December 31, 9999 Decimal 16 bytes 0 through +/- 79,228,162,514,264,337,593,543,950,335 (+/-7.9...E+28) with no decimal point; 0 through +/- 7.9228162514264337593543950335 with 28 places to the right of the decimal Double 8 bytes -1.79769313486231570E+308 through - 4.94065645841246544E-324, for negative values 4.94065645841246544E-324 through 1.79769313486231570E+308, for positive values Integer 4 bytes -2,147,483,648 through 2,147,483,647 (signed) Long 8 bytes -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807(signed)
  • 5.
    Object 4 bytes on32-bit platform 8 bytes on 64-bit platform Any type can be stored in a variable of type Object SByte 1 byte -128 through 127 (signed) Short 2 bytes -32,768 through 32,767 (signed) Single 4 bytes -3.4028235E+38 through -1.401298E-45 for negative values; 1.401298E-45 through 3.4028235E+38 for positive values String Depends on implementing platform 0 to approximately 2 billion Unicode characters UInteger 4 bytes 0 through 4,294,967,295 (unsigned) ULong 8 bytes 0 through 18,446,744,073,709,551,615 (unsigned) User- Defined Depends on implementing platform Each member of the structure has a range determined by its data type and independent of the ranges of the other members UShort 2 bytes 0 through 65,535 (unsigned)
  • 6.
    Data Types DefaultValue Size (bytes) Char 0 2 Byte 0 1 Short 0 2 Integer 0 4 Long 0 8 Single 0.0 4 Double 0.0 8 Decimal 0.0 16 Boolean False 1 Date 1/1/0001 12:00:00 Am 8
  • 7.
  • 8.
    Option Statements  Optionexplicit on/off  Option compare binary/text  Option strict on/off
  • 9.
    Option explicit on/off If option explicit on variable declaration is compulsory.  If it is off variable declaration is not compulsory.  By default it is on.
  • 10.
    Option compare binary/text By default binary  If option compare is binary comparison is case sensitive.
  • 11.
    Option strict on/off By default option strict is off
  • 12.
    Conditional Statement If conditionthen End if If condition then else End ifIf condition then Else if condition then End if
  • 13.
  • 14.
    Short circuit evaluation Andalso, orelse  VB.NET also provide two logical operators andalso, orelse that can be used to help evaluate expression as efficiently as possible.  The andalso operator is used to prohibit the evaluation of second condition if the result of the expression is known after evaluating the 1st operand.  There is a similar case with the orelse operator in this case if the 1st condition is true then 2nd condition will not be evaluated and operator return true.
  • 15.
    Select case  Selectcase variablename  Case 1  Case 2  Case else  End select
  • 16.
    Looping statements  Do……..loop While………end while  For………..next  For each………….next
  • 17.
    Exit statement  Exitfor  Exit do  Exit while
  • 18.
    Procedure and functionin VB.NET  Procedure and functions are block of code in a program. They are also termed as subprogram and are basically used to avoid repetition of same code a number of times.  By making use if procedures and functions we save time there by making development faster.
  • 19.
     Functions arealmost similar to subprocedure except that function can return value to the calling procedure. Function procedures re encloses between function and end function block. Function returns a value whereas procedure does not return a value.
  • 20.
    Passing arguments tofunction and procedures  Call by value  Call by reference
  • 21.
    Call by value It is used to pass and argument by value.  It indicated that the value of the variable should not be modified by the call procedure or function.  Hence when a variable is passed using byval keyword a copy of the variable is created within the call procedure. Any change made to the value of the variable will affect the copy not the variable itself.
  • 22.
    Call by reference It is used to indicate that the arguments are passed Byreference not value. This means that the call procedure can modify or change the variable. By passing argument by reference a procedure is given access to the original value of the variable in its memory location. As a result any changes made to the argument within the call function will be reflected in the calling procedure.
  • 23.
    Access Specifier  Private,Public  By default it is private  When declare with a public keyword elements are available throughout the current project and within a other project that are referencing the current project.  On the other hand if elements are declare as private it can only used within the current module.
  • 24.
    Arrays , Enumerationand structure  Array is an entity that contains multiple variables of the same data type.  This variables are referred to by a single name.  This variables are called as elements of an array.  An array subscripts or index is used to access each element of an array.  Array in VB.NET are classified into single and multi dimensional array.  Length property gives the total number of elements in an array.
  • 25.
    Redim statement  Theredim keyword in VB.NET allows us to change the size of array after they have been declared.  A redim statement can only be used within a procedure and not at the module level.  When the size of an array is modified using Redim keyword the original contents of an array is lost, however the contents can be retain using the keyword Preserve with Redim.
  • 26.
    Multidimentional Arrays  RectangularArrays – Rectangular arrays are multidimetional arrays where the number of elements in each row is same, which occupy adjacent memory locations.  Jagged Arrays – A jagged array is an array of arrays. When we declare a jagged array, we specify number of rows. Each row holds an array, which can be of different length.
  • 27.
    Enumeration  Enumeration areused when we need to refer the values of primitive types such as byte, short, integer as constants
  • 28.
    Structure  A structureis a composite user defined datatype using which we can group data of different data type together.  A structure can be declared with in a module but it cannot appear inside a procedure.  A Statement can contain data members as well as procedure and functions.  The scope of the data members within a structure is public.
  • 29.
    Object oriented conceptsin VB.NET  Abstraction  Encapsulation  Polymorphism  Data Hiding  Inheritance
  • 30.
    Class  A classis a representation or a template of common attributes of behavior of objects.  The content of a class are called members. Based on a class instance are created which are called objects.
  • 31.
    Properties and Methods In VB.NET data members that describes as an object are called fields or properties.  The members which describes object behavior are called methods. 
  • 32.
    Properties  Properties arean extension of variables.  They don’t denote storage location but instead have accessor which specify statements that can be executed to assign or retrieve to or from the properties.  A set accessor in a property declaration is used to assign values.  A get accessor is used to retrieve values of the property.
  • 33.
    Types of properties Write only properties – It must have set accessor and Get accessor may be omitted  Read only – It must have Get accessor, the Set accessor may be omitted.  Read / Write – This type of property must have Get as well as Set accessor.
  • 34.
    Constructor  Constructor executesautomatically every time when an object is created.  Constructors are typically declared public and are used for initialised purpose.  In VB.NET the lifetime of an object begins when it is created with the New keyword.  Constructor in VB.NET are written using sub new()…. End sub
  • 35.
    Destructor  The lifetimeof an object ends when it is destroy or goes out of the scope.  In VB.NET the destructors are written using the finalize() method.  Destructor are use for cleanup operations such as releasing of memory that is no longer required.
  • 36.
    Method Overloading  Overloadingis the process of declaring the methods of a class having same name but different signature.  The signature of the method comprises the number and the types of arguments.  In VB.NET functions, procedures, constructors and properties can be overloaded.
  • 37.
    Inheritance in VB.NET It is a process of creating classed based on existing classes.  Inheritance is based on the principle of code reuse.
  • 38.
    Access Specifiers  Public– All public elements of a class are inherited by it’s derived classes.  Private – Private elements of a class can’t be inherited by derived classes.  Protected – Protected access for elements denote that elements may be used within the derived class but not outside the derived class.
  • 39.
     Friend –Friend access modifier is used to denote that the elements accessible throughout the program in which the class is defined.  Protected Friend – This access modifier indicated that the elements contain features of both protected and friend modiers.
  • 40.
    Abstract Class  Anabstract class can’t be used to create objects.  It is generally used as as template to derive other classes. An abstract class typically has abstract methods which are only method declaration without any implementation.  In VB.NET all classes are inheritable.  The mustinherit keyword makes the base class as a abstract class
  • 41.
    Final Classes  Finalclasses in VB.Net are marked with the notinheritable keyword.  Final classes can’t have derive classes but they can be use to create objects.
  • 42.
    Method overriding  Overridingis the process of overriding the methods or properties of a base class in a derived class.  In case of method overriding the return type, name and arguments of method in the derived class must be the same as that of the method be overriden.  When an object of derived class invokes the overriden method it will be derive class implementation that will be called.  The base class method must be marked with keyword overridable and derived class method marked with keyword overrides.
  • 43.
    Shadows keyword  Ifwe wish to hide the inherited method within a derive class and invoke an overriden version of the method then we use the shadows keyword.  Shadows keyword can’t be used with the overloads keyword.
  • 44.
    Mybase keyword  Mybasekeyword is used to refer to the base class method in derived class, that has overriden method of the base class.
  • 45.
    Myclass keyword  Thiskeyword works opposite to the way in which mybase keyword works.  Assume that a base method is overriden in derived class.  If the object that is used to invoke the method is of derived class then it is always the derived class version of the method in another method of the base class.  Instead of derived class version we must use myclass keyword.
  • 46.
    Interfaces , Namespaces Interfaces are similar to classes except that they have no implementation methods. Methods are only declare within within an interface and don’t contain any code.  An interface can’t be instantiated it is typically implemented be a class using implements keyword.  An interface defines using  Interface <interfacename>  End interface
  • 47.
     A classcan’t inherit from two other classes but it can inherit a class and implement an interface.  Multiple inheritance is not supported in VB.NET.  However, it can be achieved with the help of inherfaces.
  • 48.
    Namespaces  In VB.NETclas libraries are comprises of namespaces.  Namespaces are used to organise nested entities such as other namespaces, classes, interfaces and so on.  Namespaces takes care of the way in which program elements are expose to other program with the help of various access modifiers.  Modules and classes are generally put inside namespaces.
  • 49.
    Collections  A collectionis term used to describe a means of grouping and managing related entities.  An VB.NET a collection is used to manage the objects that are used to manage the objects that are used by class.  The simplest way to create a public instance of type microsoft.visualbasic.collection in the program.
  • 50.
    Events  Events areactions that have trigger either by a user action, program logic or by the system.  Whenever an event occurs the user may either ignore an event or deal with the event with the help of suitable code.  Procedure containing codes that will process the events are called event handler.  The syntax to create an event is :-  Private/public/proceted event eventname(argument list)
  • 51.
     Once declarean event can be activated with the help of the raise event statement placed inside a subprocedure.  To process an event we may use any one of the following approaches :- ◦ Use addhandler statement to provide a reference to an event handler. ◦ Use withevents, with conjunction, withhandles keywords.
  • 52.
    Delegates  Representative  Pointerto function.  In VB.NET a delegate is define as representative of a function or a procedure it holds a reference to a method.  A delegate declaration must specify the parameter or return type for the method which it represents.  VB.NET allows us to create two types of delegate classes.
  • 53.
     Singlecast delegates Multicast delegates  Single cast delegates are delegate classes that are derived from delegate class.  Multicast delegates are derived from multicast delegate class.  Single cast delegates contains an invocation list with only method where as multicast delegate contains invocation list with one or more methods.
  • 54.
    Multithreading  Multithreading inVB.NET is accomplish through the classes and interfaces in the system.threading namespace.  To create a new thread we pass a delegate to the constructor of the system.threading thread class.  This delegate must point to a method that will act as starting point for the thread.
  • 55.
    Name property  Athread can be given a name by using name property of the thread class.
  • 56.
    Suspend and resumemethod  The suspend and resume method of system.threading thread class is used to suspend an action of the thread for indefined period.  The thread can be resume using the resume method.
  • 57.
    Synchronisation  When twoor more threads in a multithreaded application access common method or data simultaneously there will be a conflict and as a result important info could be lost or data will become inconsistent.  To avoid this it is necessary to have some kind of mechanism in a multithreaded application that allows methods or data to be access by one thread at a time.  Synchronisation is a process that allows thread to access methods or data one thread at a time.  We use Synclock keyword for it.
  • 58.
     The synclock………. End synclock block encloses the statement that are likely to cost conflict in data and act as monitor thus giving the calling thread exclusive lock.  Because of this only one thread is given priority to execute at any given time.
  • 59.
    Monitor Class  VB.NETprovides a monitor class which defines enter, try enter and exit methods.  These methods of monitor class describe below.  Enter method :- This method acquires a monitor lock for an object. This method may block execution of other methods in the current thread holds the lock.  Try Enter :- Tries to acquire a monitor lock without blocking.
  • 60.
     Exit :-This method release the monitor lock on an object.  Wait :- Wait method waits until another thread passes notification method using the PULSE method.  Pulse :- Pulse method is used to notify about the change in the state of an object to a thread that is waiting.
  • 61.
    Memory management inVB.NET  In an automatic memory management environment a garbage collector program runs as a separate thread.  The garbage collector frees memory that no longer needed.  VB.NET uses a garbage collector to implement automatic memory management.
  • 62.
    Garbage collector  Thegarbage collector needs to know when objects are no longer in use by an application.  This information is given to the garbage collector using concept called metadata.  Every element in a VB.NET includes metadata that describe it.  By means of metadata the CLR knows the layout of each object in memory.  The JIT compiler and the CLR maintains a list of active rules.  This is then made accessible to the garbage collector algorithm.
  • 63.
    Dialog Boxes  Modal– Open, Save, print  Modeless – Find, replace.
  • 64.
    Common Dialog Boxes Openfile  Savefile  Font  Color  Print dialog  Print preview  Pagesetup
  • 65.
     A dialogboxis a temporary window that contain controls that can be used to display information and messages to the user or to accept the user input so that a specific action can be carried out.
  • 66.
    Types of DialogBoxes  Modal – A modal dialog box forces the user to make a selection or perform a particular action before proceeding with an application.  For eg. If a modal dialog box is used to display a message the user will not able to switch another form unless and until the user closes the dialog box.
  • 67.
     Modeless :-This dialog boxes let the user switch to another form without having to close the dialog box.  Modeless dialog box allow user to continue to work anywhere in the current application while the dialog box is displayed.
  • 68.
    Error handling inVB.NET  Data Validation :- An application processes information that user entered. Data validation ensures that the data entered in the application is accurate and of valid data type. In winforms two data validation techniques are supported  A field level validation  A form level validation
  • 69.
    Field level validation Data in the field of the form are verified one at a time after the user enters a value into a particular field and moves on to the next field on the form.  Controls also support some methods and events that are useful for verification and validation data.  Leave event :- When a form or a control looses the focus or the cursor leaves the control, the leave event is fire.
  • 70.
     Enter event:- This event is fire when the focus is set to a field. This event can be used to check whether the value entered in the previous field is valid or not.  Validating :- This event occurs when the control is being validated. This event takes an argument of type ◦ Cancelevent args ◦ The main property of the cancelevent args argument is the cancel property. ◦ The cancel property can be set true or false to indicate whether the event has to be canceled or not.  Validated :- This event occurs after the validation of the control is completed or after the validating event is completed.
  • 71.
    Keyboard events  Themain three keyboard events used in validation are keypress, keydown, keyup  A keypress event occurs when a keyboard key is pressed while a control has focused. The keypress event takes an argument of type KeyPressEventArgs which represents the character is composed when a key is pressed.
  • 72.
    Properties of keypresseventargs Handled – The value of this property indicates whether the keypress event was handled or not.  Keychar – This property represents the character that correspond to the key press by the user.  Key down/ Key up – These events are closely related with the keypress events. The keydown event occurs before keypress event as soon as the user press a key and the keyup event occurs when the user releases the key. The key down and keyup events of types system.windows.forms.keyevent args
  • 73.
    Properties of keyeventargs Alt – It indicates whether the ALT key was press or not.  Control – It indicates whether ctrl key was press or not.  Shift - It indicates whether shift key was press or not.  Handled –  Keycode – It will return keyboard code of the key which when press triggers the keydown and keyup events.
  • 74.
    Exception Handling  Exceptionsare used to handle abnormal/exceptional conditions that arises while executing programs.  Winforms include default exception that are raised when an error occurs.  Exceptions are used to handle runtime errors.  There are two different types of exception classes supported in winforms, System.exception and application.exception.
  • 75.
    MDI  Multiple Documentinterface  A mdi application is made up of one MDI parent form and one more child form.  A MDI form is created in the same way as we create a form, when the property ISMDICONTAINER is set to true for a window form it becomes a MDI form.
  • 76.
    Collections Classes  .NETprovides the system.collections namespace that contains various interfaces and classes representing the collection of objects. The advantage of using collection classes :- ◦ Performance – Collection classes consist of efficient algorithm. ◦ Similarity – Similar operation work on dissimilar data types. ◦ Extensibility – We can extend the functionality of collection classes for any new data type.
  • 77.
    Collection Types  Orderedcollection  Indexed collection  Key collections
  • 78.
    Ordered collection  Classesthat implement the I collection interface fall under this category.  In this category the insertion and deletion of objects is order based i.e. the order in which the elements are inserted controls, the order in which they would be retrieve from the collection. E.g. Stack Queue.
  • 79.
    Indexed Collection  Herethe insertion and retrieval of elements is index based i.e. elements can be retrieve using O base numeric index.  Such collections implement the I list interface i.e. array, arraylist.
  • 80.
    Key collections  Hereelements can be inserted and retrieve using an associated key value pairs.  This classes implements the I dictionary interface i.e. hashtable , sorted list.
  • 81.
    Stack  The collectionnamespace provides a stack class, which provides Last In First Out way to store and retrieve the elements.  The operation by which an element is added to the stack is called PUSH, and the operation by which element is removed from the stack is called POP.  The member of the stack that refers last element of the stack is called TOP.
  • 82.
    Queue  The collectionnamespace also provides a queue class which provides First In First Out way to store and retrieve the elements.  The end at which first element is placed is called front and the end at which last element is placed is called rear.  A new element get’s added at the end that is at rear end and an element get removed from front end.
  • 83.
    Array List  Arraylist class is similar to the array class except that it’s size can grow dynamically.
  • 84.
    Hash table  Oneof the most efficient known data structure for fast look up is “HASH TABLE”.  In a hash table we can store pair of values and associated keys.  The value are organised on the basis of the keys.  The keys can be used to retrieve the corresponding values from the hash table.
  • 85.
    GDI+  .NET providesa set of GDI classes. This classes allows programmers to draw graphics or text without being require to bother about the specification of the video hardware.  These classes are present in system.drawing and system.drawing.drawing2D namespace.  The GDI+ classes offer device independence to our program.
  • 86.
     Device independencemeans that the same program should work with the different screens , keyboards and printers without modifying the program.  The GDI+ classes takes care of the differences in hardware allowing a programmer to concentrate on drawing.
  • 87.
    Paint Handler  Thegraphics class is a wrapper around the device context.  All methods used for drawing operations are belongs to this class.  This class is present in the system.drawing namespace.  When the onpaint eventhandler is called a reference to the painteventargs object is passed to it.  The painteventargs class contains a property access returns a reference to the graphics object.
  • 88.
    FILE I/O  Wedeal with files mainly for three purposes getting properties of a file, reading and writing data of primitive data types and reading and writing data of user defined types. For these purposes .NET provides separate set of classes.  The filesysteminfo and file classes are used for performing file operations like creating , copying m deleting and moving of files.
  • 89.
     They alsoprovide functions for getting information of a file.  The fileinfo and directoryinfo classes are derived from the filesysteminfo class.  Fileinfo class is used to perform an the file operations that we can perform using the file class.  The DirectoryInfo class is used for creating , moving through directories and subdirectories.
  • 90.
     The classesderived from the marshal Byref object class are used for marshelling the object across the application.  Marshelling means creating an object in one application and passing it’s state to another application.
  • 91.
    MarshalByRefObject TextReader Stream TextWriter String Reader Stream Reader String Writer String Writer
  • 92.
     A streamis a sequence of bytes traveling from source to destination or traveling over a communication link.  Two basic types of streams are InputStream and OutputStream.  An InputStream is used for read operation while outputstream is used for write operation.  The streamReader class inherits a textReader that reads characters from a bytestream.  The streamwriter clas inherits a textwriter for writing a character to a stream.
  • 93.
    Assembly  Assemblies arebuilding blocks of .NET application.  Components are package into assemblies.  Assembly can either be in a form of exe or dll files.  To create the assembly.  Programs->Ms visual studio 2005 -> Visual studio tools -> Visual studio 2005 command prompt.  Go to your application  Vbc/t : library module1.dll
  • 94.
    Inheritance Picker  Wecan create a new form which is inherited from another form.  The environment has something called ‘inheritance picker’ that provides that functionality.  It is possible to create a base form with logic and visual elements needed by all forms and then have other forms inherits to get that functionality.
  • 95.
     The logicand visual elements are encapsulated in one location so that changing the base form causes all the forms inheriting form it to change automatically.  This concept is called as ‘inheritance picker’.  A form must be compiled in to an executable file with the built command before it can be used by the inheritance picker.  Once that is done the menu options/ project/ add new item/inherited form allows the addition of a form that inherits from another form in the project.