Unit I

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

VB.

NET-UNIT-I

 Event Driven Programming


Event driven is a language that is based on the events that happen
during the execution of a program. These events are controlled by event handlers,
trigger functions and event loops. This basically means that nothing will happen
unless an event or series of them are triggered.
In event driven model the programs are not
procedurals any longer .one of the main features of event driven programming is
that it creates a user friendly environment, because when the user takes an action,
this action triggers a chain of events which cause the program to do what the user
want. The program waits for the event and takes the most appropriate action.
Unlike some other types the program flow is not dependant on the program, and
does not follow sequential logic. Event Driven is run by several different
procedures, all of which are designed to react to something the user does, these
reaction can be set on timer, or on placement, or can even be delayed until two
things happen simultaneously. This allows everything to be more dynamic, and
‘intelligent’.
The event Driven programming Following three things are oftenly needed.
Event Generator:-The event generators are those which actually generate
event in VB.NET. The keyboard, mouse are the event generator.
Event Source:-The event source will help in event generator in generating the
event, various controls have been provided by VB.NET. This is the source for
the event.
Event Listener:-The event listeners are those which will check for the
occurrences of an event & if an event occurs then the corresponding procedure
are been executed.

 .Net Framework 4.0 Features


Application Compatibility and Deployment

The .NET Framework 4 is highly compatible with applications that are


built with earlier .NET Framework versions, except for some changes that were
made to improve security, standards compliance, correctness, reliability, and
performance.

The .NET Framework 4 does not automatically use its version of the common
language runtime to run applications that are built with earlier versions of the .NET
Framework. To run older applications with .NET Framework 4, you must compile
your application with the target .NET Framework version specified in the

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

properties for your project in Visual Studio, or you can specify the supported
runtime with the <supported Runtime> Element in an application configuration
file.

Dynamic Language Runtime (DLR)

The Dynamic Language Runtime (DLR) Feature is introduced in .NET


Framework 4.0 to implement dynamic language, such as Python and Ruby, on the
.NET Framework. This implied that the DLR is a runtime environment that adds
services to the CLR, to implement dynamic languages. This Feature has been
introduced in the new version of .NET Framework as the dynamic languages are
the commonly used scripting languages and the user can extend the applications,
which are created using dynamic languages.

The purpose of DLR is to enable the dynamic languages to run on the .NET
Framework and provide the advantages of .NET interoperability to dynamic
languages. New System. Dynamic namespace has been added in this version of
.NET Framework to support the DLR Functionality.

Managed Extensibility Framework

The Managed Extensibility Framework (MEF) is a new library in the .NET


Framework 4 that helps you build extensible and compos able applications. MEF
enables you to specify points where an application can be extended, to expose
services to offer to other extensible applications and to create parts for
consumption by extensible applications. It also enables easy discoverability of
available parts based on metadata, without the need to load the assemblies for the
parts.

Parallel Computing

The .NET Framework 4 introduces a new programming model for writing


multithreaded and asynchronous code that greatly simplifies the work of
application and library developers. The new model enables developers to write
efficient, fine-grained, and scalable parallel code in a natural idiom without having
to work directly with threads or the thread pool. The new System.Threading.Tasks
namespace and other related types support this new model.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Improve security Model

A new and improve security model has been introduced in .NET


Framework 4.0 . a major change has been introduced in the code access security
system. In .NET Framework 4.0 the security policy is not applied to all
applications and the desktops applications, which includes both the applications on
computer and on the network, are now executed as full-trust applications. There
are many useful classes and services introduced in CLR and .NET Framework that
help the developers to write secure code and implement cryptography and role-
base security.

Improvement core ASP.NET services

ASP.NET version 4 introduces new features in the following areas:

 Core services, including a new API that lets you extend caching, support for
compression for session-state data, and a new application preload manager
(autostart feature).
 Web Forms, including more integrated support for ASP.NET routing,
enhanced support for Web standards, updated browser support, new features
for data controls, and new features for view state management.
 Web Forms controls, including a new Chart control.
 MVC, including new helper methods for views, support for partitioned
MVC applications, and asynchronous controllers.
 Dynamic Data, including support for existing Web applications, support for
many-to-many relationships and inheritance, new field templates and
attributes, and enhanced data filtering.
 Microsoft Ajax, including additional support for client-based Ajax
applications in the Microsoft Ajax Library.
 Visual Web Developer, including improved IntelliSense for JScript, new
auto-complete snippets for HTML and ASP.NET markup, and enhanced
CSS compatibility.
 Deployment, including new tools for automating typical deployment tasks.
 Multi-targeting, including better filtering for features that are not available in
the target version of the .NET Framework

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Improvements Windows Presentation Foundation (WPF)

Windows Presentation Foundation (WPF) version 4 contains changes and


improvements in the following areas:

 New controls, including Calendar, Data Grid, and Date Picker.


 Visual State Manager supports changing states of controls.
 Touch and Manipulation enables you to create applications that receive input
from multiple touches simultaneously on Windows 7.
 Graphics and animation supports layout rounding, Pixel Shader version 3.0,
cached composition, and easing functions.
 Text has improved text rendering and supports customizing the caret color
and selection color in text boxes.
 Binding is supported on the Command property of an InputBinding,
dynamic objects, and the Text property.
 XAML browser applications (XBAPs) support communication with the Web
page and support full-trust deployment.
 New types in the System.Windows.Shell namespace enable you to
communicate with the Windows 7 taskbar and pass data to the Windows
shell.
 The WPF and Silverlight Designer in Visual Studio 2010 has various
designer improvements to help create WPF or Silverlight applications.

Improved Entity Framework

In this version of .NET Framework there is less amount of


coding in Entity Framework the amount maintenance required for data-driven
application has also been reduced by allowing you to program against data models.
Creation of conceptual models in which the columns with foreign key in the
database correspond to entity types. Also introduced of new method in the
System.Data.Objects namespace so that the N-tire application are developed easily

Windows Communication Foundation

Windows Communication Foundation (WCF) provides the following


improvements:

 Configuration-based activation: Removes the requirement for having an .svc


file.
 System.Web.Routing integration: Gives you more control over your
service's URL by allowing the use of extensionless URLs.
BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR
VB.NET-UNIT-I

 Multiple IIS site bindings support: Allows you to have multiple base
addresses with the same protocol on the same Web site.
 Routing Service: Allows you to route messages based on content.
 Support for WS-Discovery: Allows you to create and search for discoverable
services.
 Standard endpoints: Predefined endpoints that allow you to specify only
certain properties.
 Workflow services: Integrates WCF and WF by providing activities to send
and receive messages, the ability to correlate messages based on content, and
a workflow service host.

Windows Workflow Foundation

Windows Workflow Foundation (WF) provides improvements in the following


areas:

 Improved workflow activity model: The Activity class provides the base
abstraction of workflow behavior.
 Rich composite activity options: Workflows benefit from new flow-control
activities that model traditional flow-control structures, such as Flowchart,
Try Catch, and Switch<T>.
 Expanded built-in activity library: New features of the activity library
include new flow-control activities, activities for manipulating member data,
and activities for controlling transactions.

 VB.NET Environment

You can develop Visual Basic.NET applications using Visual Studio 2010
Integrated Development Environment (IDE).Microsoft Visual Studio 2010 was
released on April 12, 2010 with .NET Framework 4.0.Visual Studio 2010 IDE is a
powerful environment which contains all the tools you need to develop Visual
Basic.NET applications efficiently.
Microsoft provides the following development tools for VB.Net programming:
 Visual Studio 2010 (VS)
 Visual Basic 2010 Express (VBE)
 Visual Web Developer
When we create a new window application in Visual Studio 2010, Visual Studio
2010 IDE looks like as given in the diagram:

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

 Title Bar
Title bar shows the name of the current project, such as WindowsApplication1 in
the diagram.

 Menu Bar
The Menu Bar provides various menus for controlling the various
operations of Visual Studio 2010 IDE. It contains various menus like File, Edit,
View, Debug etc.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

 Standard Toolbar
The Standard Toolbar provides some buttons as shortcuts to some of the menu
option.

 Solution Explorer
The Solution Explorer window is a key part of Visual Studio, and is
frequently used by developers. It allows you to navigate around the various files
and other items that make up your projects and your solution. Generally,
double‐clicking on a file will open that file, either in a text editor or perhaps some
kind of visual design surface. Some files can be edited in various ways. For
example, you will notice that when the project was created, the file Form1.dbl was
automatically created, added to the project, and opened in design view. But there is
another way of working with Form1.dbl, in a source code editor. To see this in
action:
 In Solution Explorer, right‐click Form1.dbl and select View Code.
When working with pieces of a UI it is common to work with these two
Views of a given source file, the design view and the code view.
 Right‐click Form1.dbl again and this time select View Designer.

You may have noticed that once a file (or a view of a file) is opened, it
remains open until you specifically close it. Each file is assigned a tab towards the
top of the main work area, which looks like this:

You can use these tabs to switch between the views of a file, or between
multiple files that you have opened. You’ll also notice an X to the right of each
tab, which can be used to close that file or view. You may sometimes see red dots
next the file name on a tab. This is an indication that the file has been modified and
needs to be saved. Visual Studio will automatically save files when you build or
run, and there are also various ways to manually save one or more files. The easiest
way to manually save files is to use the Ctrl+S shortcut to save the current file, or
the Ctrl+Shift+S shortcut to save all changed files.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

It is easy to change the layout of the UI in Visual Studio, where most things
can be repositioned, docked, stacked in tab sets, and hidden away at will. If at any
time you can’t find Solution Explorer you can always make it visible by selecting
View > Solution Explorer from the menu, or by using the keyboard shortcut
Ctrl+Alt+L.

 Form Design Surfaces


Many things that you work with in Visual Studio have visual design
surfaces. Certainly it is common to work with a visual design surface when
building a user interface, but several other things have them also. As the name
suggests, a visual design surface allows you to design something visually, often by
dragging items from a palette of available “things” and arranging them on the
design surface.
Right now we are creating a Windows Forms application, so we have access
to a wide variety of components that can be used to build a Windows user
interface. These components include things like the TextBox, CheckBox and
Button controls that you’re probably familiar with. These controls are located in

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

the Toolbox (more in a moment) and can be dragged to the visual(Form) design
surface as needed.

By the way, the same concept also applies when working with other types
of application. As well as with traditional Windows Forms applications, developers
commonly work with visual design surfaces and toolboxes when developing
Windows Presentation Foundation (WPF) applications, ASP.NET Web
applications, Silver light applications, and others.

 The Toolbox
The Toolbox may not be visible right now, but if not look down the left
Hand side of the Visual Studio window and you may see a vertical tab that
Says Toolbox.
 If you don’t see the Toolbox Window then select View > Toolbox
from the menu (or type Ctrl+Alt+X).
 With the Toolbox visible, click on the small icon at the top right
of the Toolbox window to “pin” the window in place.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Pinning a window provides a mechanism to ensure that it remains on the


screen. Most windows, when unpinned, slide out of sight but leave behind a tab so
that you can access the window again. Hovering the mouse over the one of these
tabs will make the window appear so that you can access it, or pin it in place.

 Make sure that the design view of Form1.dbl is visible.


 In the Toolbox, go to the Common Controls group, then click once
on and drag a Button control to the design surface.

You will notice that when the button is created on the form, several white
“handles” appear around the outside of the button. These handles perform two
functions; they indicate which item is currently selected to be worked with, and
they can be used to resize the selected item.
 Single‐click the body of the form (not on the button) and you will see that
the handles move to the form, which is now selected to be worked on.
 Single‐click on the button again, the handles move back to the button.
As you click between these two items, look to the lower right portion of the
screen. You should see a window called Properties, and you should see the
content of the window change as you select different items on a visual design
surface.

 If you can’t see the properties window, select View > Properties Window
from the menu, or use the F4 keyboard shortcut.
 If necessary, pin the properties window in place.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

 Properties Window
The properties window is another key part of Visual Studio where, if
you’re developing a user interface at least, you are likely to spend a lot of time.
Essentially each item that you work with (buttons, textboxes, checkboxes, etc.)
have properties, sometimes hundreds of them, and the properties window allows
you to inspect and change the values of these properties, in order to achieve the
desired functionality within your application.
Notice the mini toolbar at the top of the properties window; in fact many of
Visual Studio’s windows have a similar toolbar, which generally allows you to
view the information in the window in various ways. For example, the properties
window is currently grouping the various properties of the selected button control
by type (Accessibility, Appearance, etc.) because the first button on the toolbar is
selected.
 Click on the second icon to order the properties alphabetically.
Notice that the properties window also has a drop‐down list (at the top) which
shows you which item is currently selected. Another way of changing the selected
item is to drop down this list and select a different item.
 Drop‐down the list at the top of the properties window and select Form1.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Notice how the selected item handles moved from the button to the
form, and how the content of the properties window changed to reflect the
properties of the newly selected item.

 On Form1’s design view, select the form.


 In the properties window, Locate the Text property and set the value to
My Form.
A Windows Form’s text property is used to set the title of the window;
notice how the text that you typed is now also displayed in the title area of
the form designer. Some changes that you make in the properties window
are reflected visually in the designer. In some cases, the opposite is also
true. For example:
 With the form selected, locate the Size property. It may be easier to
switch to alphabetic mode (toolbar at top of properties window).
 Notice the current value of the size property; probably the default
300, 300
 Now use the designer’s current item handles to visually resize the
form.
 Check the Size property again, it should have changed.
So, making changes in the properties window often visually changes
the designer window, and making changes in the designer window also
changes the properties window.
Another thing to notice with respect to the properties window is how
properties that have not been changed (i.e., currently have a default value)
are displayed in normal text, whereas properties that have had their value
changed are displayed in bold text. This visual indication of what
properties have been changed can be very useful.
So, we’ve discovered that we can change the properties of something
either graphically in a design view,or via the properties window, but where
is all of that information stored? The answer to that depends on what type
of project you are working on. Some common examples are:
Project Type Designer / Properties Changes Written To
Windows Forms A “designer” programming language source file.
Web Forms (ASP.NET) The main web page file (.aspx) in HTML format.
Windows Presentation Foundation The main form or control file (.xaml)
in XAML format.
Silver light The main form or control file (.xaml) in XAML format.
Other Various, generally a programming language source file.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

 Object Browser
Visual Studio’s Object Browser window allows you to browse and view
the content of assemblies.
 In Solution Explorer, double‐click on the System.ServiceModel
reference that you just added.
You should see the Object Explorer window open, and the System. Service
Model assembly should be selected in the list of assemblies to the left side of the
screen. Similar to the .NET tab in the add reference dialog, this list shows
assemblies that are provided by the .NET Framework as well as other Assemblies
that you may have referenced in your project. At the top of the dialog is a toolbar
with a drop‐down list which allows you to apply filters to the list of assemblies that
are displayed.
 In the Browse drop‐down list, select .NET Framework 4 to filter the list
of assemblies to only those assemblies available in that version of the
.NET Framework.
 Click the small triangle icon next to the System.ServiceModel assembly.
Assemblies can contain types (classes, etc.) from one or more namespaces.
When you drill into an assembly in Object Browser, the first thing you see is the
namespaces that are present in the assembly:

Above you can see that the System .Service Model assembly contains types
from multiple namespaces. Note that the types in a namespace don’t have to be all
defined in one assembly. For example, you can see that this namespace contains
some types from the System namespace, but there will be types from the same
namespace in other assemblies too.
 Click the triangle icon next to the System.ServiceModel namespace to
drill into it.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Drilling into a namespace displays the types that are present in that
namespace. The nature of the type is indicated by the icon displayed next
to it. For example, in the diagram above, Action Not Supported Exception
is a class while Audit Level is an enumeration.

 Single‐click on the class BasicHttpBinding to select it.

In the upper‐right section of the Object Browser window you can see
more detail about the type that you have selected, and again the icon next to each
item indicates the nature of the item. In the case of the Basic Http Binding class,
you will see that the class has several methods, one of which is called
CreateBindingElements (), and also several properties, including by pass Proxy on
Local.
 Single‐click on the CreateBindingElements method to select it.
In the lower‐right portion of the Object Browser window you can see even
more information about the thing that you have selected above.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

In this case the information is telling us about the method that we


selected. We can see that it is a public method, so it’s available for us to
call, it does not have any parameters (nothing is listed between the
parentheses following the method name) and it returns a Binding Element
Collection. There is also useful descriptive information about what the
method does, any parameters it might accept, and the return value.
You may also notice that other types that are mentioned here appear
to be hyperlinks, and sure enough clicking on one of them will take you to the
documentation for that type in Object Browser. There are also forward and
back buttons on the toolbar to make navigating around easy, just like in a web
browser.
You can also use Object Browser to add references to your project.
For example, let’s suppose that by browsing around in Object Browser we
Determined that we need a reference to the System. Service Model.
Activation assembly.

 In Object Browser select the System.ServiceModel.Activation assembly


 In Object Browser toolbar, click the Add to References in Selected
Project in Solution Explorer button.
Object Browser can be very useful. If you have an idea about what
you need then it can allow you to easily browse detailed information about
things, and, having confirmed what you need, you can add a reference to
the required assembly.
Object browser is also a great way to learn about the capabilities of
things, because it makes it easy to view detailed information about
methods, parameters, return values, enumerations, and lots of other things.
 Close Object Browser by clicking on the cross icon in its main
tab.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

 The Output Window


Generally the output from a build is displayed in one or two places
depending on whether the build was successful. First, the actual textual output is
displayed in the Output window, and then, if there were any errors, those errors
are generally parsed and displayed in a more structured way in the Errors window.
Follow these steps to ensure that the output and errors windows are visible.
 From the menu, select View > Output (or type Ctrl+Alt+O)
 If the error window is not pinned in place, then pin it in place by
clicking the small push‐pin icon at the top‐right corner of the
window.
 From the menu, select View > Error List (or type Ctrl+\ and
then E)
Now to build the project:
 From the menu, select Build > Build Solution (or type Ctrl+Shift+B)
You should see the output window become focused, and output similar to this:
‐ Build started: Project: Intro To Visual Studio, Configuration: Debug Any CPU ‐
======== Build: 1 succeeded or up‐to‐date, 0 failed, 0 skipped ==========
This output indicates that the project was built successfully.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

 Create a project in VB.NET


The steps to create a project in VB.NET are given below:
1. Open Microsoft Visual Studio 2010.
2. Now click on File->New project as shown in the diagram given below:

3. This will open a New Project dialog box in front of you as given in the
following figure:

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

4. You can create console, web, WCF Services, Windows and so many
applications in VB.NET. Here we are going to create a Windows Application so
select Visual Basic language and Windows Forms Application from the pane and
give it a name as “First Project” as shown in the figure given below:

5. Now Click on OK button. This will create a project containing a single


Windows form with the file name as Form1.vb as shown in figure.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

6. You can place a control on the form to develop a meaningful application and
you can also rename the form.

Saving a VB.NET Project


In this section we will study “How to save a project in VB.NET?”
You can save a project by any of the following ways:
•Click on File-> Save All
OR
•Click on the button from the standard toolbar.

This will open a “Save Project” dialog box in front of you as given in the following
diagram:

Now provide the name for your location and also select the location where you
want to save your project. Solution name would be same as the Name. At last click
on the Save button this will save your project at the specified location.

Executing a VB.NET Project


In this section we will study “How to execute a project in VB.NET?”
You can execute a project by any of the following ways:
•Select Debug-> Start Debugging from menu bar.
OR
•Click on the button from the standard toolbar.
Or
•Press key F5.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

 VB.NET Console Applications


A. You can also create a console application in VB.NET.
B.Console Applications are command-line based applications which read
characters from the console and write character to the console and are executed in
DOS Version.
C.Now we will study how to create a console application in VB.NET:
1) Open Microsoft Visual Studio 2010.
2) Now click on File->New Project option. This will open a New Project dialog
box in front of you.
3) Now choose Visual Basic language and Console Application from the project
pane and also give it the name “FirstConsoleApplication” as shown in figure:

4) A console application does not have a form window. It only contains a code-
behind file as shown in figure given below:

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

5) Now add the following highlighted code to code behind file of console
application that is Module.1vb:

Module Module1
Sub Main ()
Console.WriteLine ("My First Visual Basic.NET Console Application")
Console.ReadLine ()
End Sub
End Module

6) In the above code WriteLine method of the Console class is used to display a
message on the console and the ReadLine method of the Console class is used to
read the next line of characters from the console.
7) Now press F5 key to run the application. The application will produce the
following output:

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

 The fundamental Visual Basic .NET Data types are:


1. Boolean
The Boolean type is limited to two values: True and False. Visual Basic .NET
includes many
2. Byte
The Byte type can hold a range of integers from 0 through 255. It represents
the values that can be held in eight bits of data. It can allocate 1 byte memory for
storage .The underlying .NET type is System. Byte.
3. Char
The Char data type can hold any Unicode character. The Char data type can
hold a range of character from 0 through 65535.it can allocate 2 bytes for storage.
The Char data type is new to Visual Basic .NET. The underlying .NET type is
System. Char. Unicode is a 16-bit character-encoding scheme that is standard
across all platforms, programs, and languages (human and machine).
4. Date
The Date type holds values that specify dates and times. The range of values
is from midnight on January 1, 0001 (0001-01-01T00:00:00) through 1 second
before midnight on December 31, 9999 (9999-12-31 T23:59:59). It can allocate 8
bytes for storage. The Date type contains many members for accessing, comparing,
and manipulating dates and times. The underlying .NET type is System.DateTime.
5. Decimal
The Decimal type holds decimal numbers with a precision of 28 significant
decimal digits. Its purpose is to represent and manipulate decimal numbers without
the rounding errors of the Single and Double types. It can allocate 16 bytes for
storage. The underlying .NET type is System. Decimal. Value range of decimal
data type from 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
6. Double
The Double type holds a 8 bytes, 64-bit value that conforms to IEEE
standard 754 for binary floating point arithmetic. The Double type holds floating
point numbers in the range -1.7976931348623157E308 through
1.7976931348623157E308. The smallest nonnegative number (other than zero)
that can be held in a Double is 4.94065645841247E-324. The underlying .NET
type is System. Double.
7. Integer
The Integer type holds integers in the range -2147483648 through 2147483647.
The Visual Basic .NET Integer data type can allocate 4 bytes memory for storage.
The underlying .NET type is System.Int32.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

8. Long
The Long type holds integers in the range -9223372036854775808 through
9223372036854775807. In Visual Basic .NET, long is a 64-bit integer data type.
The Visual Basic .NET long data type can allocate 8 bytes memory for storage.
The underlying .NET type is System.Int64.
9. Object
The Object type is the base type from which all other types are derived. Any
type can be stored in a variable of type Object. The Visual Basic .NET Object data
type replaces the Variant in VB 6 as the universal data type. The underlying .NET
type is System. Object. It can allocate 8 bytes on 64-bit platform.
10. Short
The Short type holds integers in the range -32768 through 32767. The Short
data type can allocate 2 bytes memory storage. The underlying .NET type is
System.Int16.
11. Single
The Single type holds a 32-bit value that conforms to IEEE standard 754 for
binary floating point arithmetic. The Single type holds floating point numbers in
the range -3.40282347E38 through 3.40282347E38. The smallest nonnegative
number (other than zero) that can be held in a Double is 1.401298E-45.the single
data can be used 4 bytes memory for storage. The underlying .NET type is System.
Single.
12. String
The String type holds a sequence of Unicode characters. The underlying .NET
type is System. String. It can have the range of 0 to approximately 2 billion
Unicode characters. It can used memory for storage depending on implementing
platform
Of the fundamental types, Boolean, Byte, Char, Date, Decimal, Double,
Integer, Long, Short, and Single (that is, all of them except Object and String) are
value types. Object and String are reference types.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

 Variable Declaration in VB.Net


The Dim statement is used for variable declaration and storage allocation for one
or more variables. The Dim statement is used at module, class, structure, procedure
or block level.

Syntax for variable declaration in VB.Net is:

[ < attributelist> ] [ accessmodifier ] [[ Shared ] [ Shadows ] | [ Static ]]


[ ReadOnly ] Dim [ WithEvents ] variablelist

Where,

 attributelist is a list of attributes that apply to the variable. Optional.


 accessmodifier defines the access levels of the variables, it has values as -
Public, Protected, Friend, Protected Friend and Private. Optional.
 Shared declares a shared variable, which is not associated with any specific
instance of a class or structure, rather available to all the instances of the
class or structure. Optional.
 Shadows indicate that the variable re-declares and hides an identically
named element, or set of overloaded elements, in a base class. Optional.
 Static indicates that the variable will retain its value, even when the after
termination of the procedure in which it is declared. Optional.
 ReadOnly means the variable can be read, but not written. Optional.
 WithEvents specifies that the variable is used to respond to events raised by
the instance assigned to the variable. Optional.
 Variablelist provides the list of variables declared.

Each variable in the variable list has the following syntax and parts:

variablename[ ( [ boundslist ] ) ] [ As [ New ] datatype ] [ = initializer ]

Where,

 variablename: is the name of the variable


 boundslist: optional. It provides list of bounds of each dimension of an
array variable.
 New: optional. It creates a new instance of the class when the Dim statement
runs.
 datatype: Required if Option Strict is On. It specifies the data type of the
variable.
BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR
VB.NET-UNIT-I

 initializer: Optional if New is not specified. Expression that is evaluated and


assigned to the variable when it is created.

Some valid variable declarations along with their definition are shown here:

Dim StudentID As Integer


Dim StudentName As String
Dim Salary As Double
Dim count1, count2 As Integer
Dim status As Boolean
Dim exitButton As New System.Windows.Forms.Button
Dim lastTime, nextTime As Date

Variable Initialization in VB.Net


Variables are initialized (assigned a value) with an equal sign followed by a
constant expression. The general form of initialization is:

variable_name = value;

for example,

Dim pi As Double
pi = 3.14159

You can initialize a variable at the time of declaration as follows:

Dim StudentID As Integer = 100


Dim StudentName As String = "Bill Smith"

Example

Try the following example which makes use of various types of variables:

Module variablesNdataypes
Sub Main()
Dim a As Short
Dim b As Integer
Dim c As Double
a = 10
b = 20

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

c=a+b
Console.WriteLine("a = {0}, b = {1}, c = {2}", a, b, c)
Console.ReadLine()
End Sub
End Module

When the above code is compiled and executed, it produces the following result:

a = 10, b = 20, c = 30

Accepting Values from User


The Console class in the System namespace provides a function ReadLine for
accepting input from the user and store it into a variable. For example,

Dim message As String


message = Console.ReadLine

The following example demonstrates it:

Module variablesNdataypes
Sub Main()
Dim message As String
Console.Write("Enter message: ")
message = Console.ReadLine
Console.WriteLine()
Console.WriteLine("Your Message: {0}", message)
Console.ReadLine()
End Sub
End Module

When the above code is compiled and executed, it produces the following result
(assume the user inputs Hello World):

Enter message: Hello World


Your Message: Hello World

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

 Scope of Variable
The scope of a variable or constant is the set of all code that can refer to it
without qualifying its name. A variable's scope is determined by where the variable
is declared. It's usually a good idea to make the scope of variables or constants as
narrow as possible (block scope is the narrowest). This helps conserve memory and
minimizes the chances of your code referring to the wrong item. I'll take a look at
the different kinds of scope in VB .NET here.

1. Block Scope

A block is a series of statements terminated by an End, Else, Loop, or Next


statement, and an element declared within a block can be used only within that
block. Here's what block scope looks like in an example. In this case, I'll declare a
variable, strText in an If statement. That variable can be used inside the If
statement's block, but not outside (VB .NET will tag the second use here as a
syntax error):

Module Module1
Sub Main()
Dim intValue As Integer = 1
If intValue = 1 Then
Dim strText As String = "No worries."
System.Console.WriteLine(strText)
End If
System.Console.WriteLine(strText) 'Will not work!
End Sub
End Module

2. Procedure Scope

An element declared within a procedure is not available outside that


procedure, and only the procedure that contains the declaration can use it.
Elements at this level are also called local elements, and you declare them with the
Dim or Static statement.

Note also that if an element is declared inside a procedure but outside any
block within that procedure, the element can be thought of as having block scope,
where the block is the entire procedure.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

3. Module Scope

When discussing scope, Visual Basic uses the term module level to apply
equally to modules, classes, and structures. You can declare elements at this level
by placing the declaration statement outside of any procedure or block within the
module, class, or structure.

When you make a declaration at the module level, the accessibility you choose
determines the scope. The namespace that contains the module, class, or structure
also affects the scope.

Elements for which you declare Private accessibility are available for
reference to every procedure in that module, but not to any code in a different
module. The Dim statement at module level defaults to Private accessibility, so it
is equivalent to using the Private statement. However, you can make the scope and
accessibility more obvious by using Private. In this example, I've declared
Function1 as private to Module2, so it's inaccessible in Module1 (VB .NET will
tag Module2.Function1 below as a syntax error):

Module Module1
Sub Main()
System.Console.WriteLine(Module2.Function1()) 'Will not work!
End Sub
End Module

Module Module2
Private Function Function1() As String
Return "Hello from Visual Basic"
End Function

End Module

4. Namespace Scope

If you declare an element at module level using the Friend or Public


statement, it becomes available to all procedures throughout the entire namespace
in which it is declared. Note that an element accessible in a namespace is also
accessible from inside any namespace nested inside that namespace.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

A Variable’s Scope : The scope of a variable is the section of the application


that can see and manipulate the variable. If a variable is declared within a
procedure, only the code in the specific procedure has access to that variable.
When the variable’s scope is limited to a procedure it’s called local.

e.g.

Private Sub Command1_Click()

Dim i as Integer

Dim Sum as Integer

For i=0 to 100 Step 2

Sum = Sum +i

Next

MsgBox “ The Sum is “& Sum

End Sub

A variable whose value is available to all procedures within the same Form or
Module are called Form-wide or Module-wide and can be accessed from within all
procedures in a component. In some situations the entire application must access a
certain variable. Such variable must be declared as Public.

Lifetime of a Variable: It is the period for which they retain their value.
Variables declared as Public exist for the lifetime of the application. Local
variables, declared within procedures with the Dim or Private statement, live as
long as the procedure.

You can force a local variable to preserve its value between procedure calls
with the Static keyword. The advantage of using static variables is that they help
you minimize the number of total variables in the application.

Variables declared in a Form outside any procedure take effect when the Form
is loaded and cease to exist when the Form is unloaded. If the Form is loaded
again, its variables are initialized, as if it’s being loaded for the first time.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

 VB.NET Type Conversions (type Casting)


Definition: Casting refers to the process of converting an expression from one data
type to another.
Conversion is based on type compatibility and data compatibility.
There are two types of conversions:

1. Implicit Conversion (Widening Conversion)


2. Explicit Conversion (Narrowing Conversion)

Implicit Conversion
Implicit Conversion performs automatically in VB.NET, that is the compiler is
taking care of the conversion. A Widening conversion is one that casts data from a
data type with a narrower range of possible values to a data type with a wider
range of possible values. In implicit conversion the compiler will make conversion
for us without asking. Byte -> Short -> Integer -> Long -> Decimal -> Single ->
Double is an example of data compatibility.
Complier checks for type compatibility at compilation.

 Visual Basic uses implicit cast to do widening conversion automatically.


 When you do arithmetic expression, Visual Basic does widening
conversions implicitly so all operands have the widest data type used in the
expression.

Practical demonstration of implicit conversion


Module Module1
Sub Main()
Dim num1 As Integer = 100
Dim num2 As Integer = 75
Dim total As Long
'In this the Integer values are implicitly converted to Long data type
'you need not to tell compiler to do the conversion, it automatically does
total = num1 + num2
Console.WriteLine("Total is : " & total)
Console.ReadLine()
End Sub
End Module

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Explicit Conversion
Explicit Type Conversions
In some cases we have to perform conversions that are the compiler does not
automatically convert a type to another. This type of conversion is called explicit
conversion. An explicit conversion uses a type conversion keyword. With these
conversion keywords we hav to perform the Explicit Conversion. A Narrowing
conversion is one that casts data from a wider data type to a narrower data type.
In explicit conversion we specifically ask the compiler to convert the value
into another data type.CLR checks for data compatibility at runtime. Explicit
conversion is carried out using casts. When we cast one type to another, we
deliberately force the compiler to make the transformation.
You should never expect that the cast would give you best or correct result. Casts
are potentially unsafe. Casting of big data type into small may lead to loosing of
data.

Practical demonstration of explicit conversion


Module Module1
Sub Main()
Dim num As Integer
Dim marks As Decimal = 34.75
'In this the Decimal values are explicitly converted to Integer data type with
rounding the marks 35
'you have to tell compiler to do the conversion, it uses casting
num = CInt(marks)
Console.WriteLine("Converted value is: " & num)
Console.ReadLine()
End Sub
End Module

In arithmetic expression, explicit casts are done before any of the other operations.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

The Type Conversion Functions in VB.Net


VB.Net provides the following in-line type conversion functions:

S.N Functions Description

1 CBool(expression) Converts the expression to Boolean data type.

2 CByte(expression) Converts the expression to Byte data type.

3 CChar(expression) Converts the expression to Char data type.

4 CDate(expression) Converts the expression to Date data type

5 CDbl(expression) Converts the expression to Double data type.

6 CDec(expression) Converts the expression to Decimal data type.

7 CInt(expression) Converts the expression to Integer data type.

8 CLng(expression) Converts the expression to Long data type.

9 CObj(expression) Converts the expression to Object type.

10 CSByte(expression) Converts the expression to SByte data type.

11 CShort(expression) Converts the expression to Short data type.

12 CSng(expression) Converts the expression to Single data type.

13 CStr(expression) Converts the expression to String data type.

14 CUInt(expression) Converts the expression to UInt data type.

15 CULng(expression) Converts the expression to ULng data type.

16 CUShort(expression) Converts the expression to UShort data type.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Example:

The following example demonstrates some of these functions:

Module DataTypes
Sub Main()
Dim n As Integer
Dim da As Date
Dim bl As Boolean = True
n = 1234567
da = Today
Console.WriteLine(bl)
Console.WriteLine(CSByte(bl))
Console.WriteLine(CStr(bl))
Console.WriteLine(CStr(da))
Console.WriteLine(CChar(CChar(CStr(n))))
Console.WriteLine(CChar(CStr(da)))
Console.ReadKey()
End Sub
End Module

When the above code is compiled and executed, it produces the following result:

True
-1
True
12/4/2012
1
1

 VB.Net - Constants
The constants refer to fixed values that the program may not alter during its
execution. These fixed values are also called literals.Constants can be of any of the
basic data types like an integer constant, a floating constant, a character constant,
or a string literal. The constants are treated just like regular variables except that
their values cannot be modified after their definition.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Declaring Constants
In VB.Net, constants are declared using the Const statement. The Const
statement is used at module, class, structure, procedure, or block level for use in
place of literal values.

The syntax for the Const statement is:

[ < attributelist> ] [ accessmodifier ] [ Shadows ]


Const constantlist

Where,

 attributelist: specifies the list of attributes applied to the constants; you can
provide multiple attributes separated by commas. Optional.
 accessmodifier: specifies which code can access these constants. Optional.
Values can be either of the: Public, Protected, Friend, Protected Friend, or
Private.
 Shadows: this makes the constant hide a programming element of identical
name in a base class. Optional.
 Constantlist: gives the list of names of constants declared. Required.

Where, each constant name has the following syntax and parts:

constantname [ As datatype ] = initializer

 constantname: specifies the name of the constant


 datatype: specifies the data type of the constant
 initializer: specifies the value assigned to the constant

For example,

'The following statements declare constants.'


Const maxval As Long = 4999
Public Const message As String = "HELLO"
Private Const piValue As Double = 3.1415

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Example

The following example demonstrates declaration and use of a constant value:

Module constantsNenum
Sub Main()
Const PI = 3.14149
Dim radius, area As Single
radius = 7
area = PI * radius * radius
Console.WriteLine("Area = " & Str(area))
Console.ReadKey()
End Sub
End Module

When the above code is compiled and executed, it produces the following result:

Area = 153.933

Print and Display Constants in VB.Net


VB.Net provides the following print and display constants:

Constant Description
vbCrLf Carriage return/linefeed character combination.
vbCr Carriage return character.
vbLf Linefeed character.
vbNewLine Newline character.
vbNullChar Null character.
Not the same as a zero-length string (""); used for calling
vbNullString
external procedures.
Error number. User-defined error numbers should be greater
vbObjectError than this value. For example:
Err.Raise(Number) = vbObjectError + 1000
vbTab Tab character.
vbBack Backspace character.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

 VB.Net - Operators
An operator is a symbol that tells the compiler to perform specific mathematical or
logical manipulations. VB.Net is rich in built-in operators and provides following
types of commonly used operators:

 Arithmetic Operators
 Comparison Operators
 Logical/Bitwise Operators
 Bit Shift Operators
 Assignment Operators
 Miscellaneous Operators

This tutorial will explain the most commonly used operators.

Arithmetic Operators
Following table shows all the arithmetic operators supported by VB.Net. Assume
variable A holds 2 and variable B holds 7, then:

Show Examples

Operator Description Example


^ Raises one operand to the power of another B^A will give 49
+ Adds two operands A + B will give 9
- Subtracts second operand from the first A - B will give -5
* Multiplies both operands A * B will give 14
Divides one operand by another and returns a
/ B / A will give 3.5
floating point result
Divides one operand by another and returns
\ B \ A will give 3
an integer result
Modulus Operator and remainder of after an
MOD B MOD A will give 1
integer division

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Comparison Operators
Following table shows all the comparison operators supported by VB.Net. Assume
variable A holds 10 and variable B holds 20, then:

Show Examples

Operator Description Example


Checks if the values of two operands are
= equal or not; if yes, then condition becomes (A = B) is not true.
true.
Checks if the values of two operands are
<> equal or not; if values are not equal, then (A <> B) is true.
condition becomes true.
Checks if the value of left operand is greater
> than the value of right operand; if yes, then (A > B) is not true.
condition becomes true.
Checks if the value of left operand is less
< than the value of right operand; if yes, then (A < B) is true.
condition becomes true.
Checks if the value of left operand is greater
>= than or equal to the value of right operand; (A >= B) is not true.
if yes, then condition becomes true.
Checks if the value of left operand is less
<= than or equal to the value of right operand; (A <= B) is true.
if yes, then condition becomes true.

Apart from the above, VB.Net provides three more comparison operators, we give
a brief description here.

 Is Operator - It compares two object reference variables and determines if


two object references refer to the same object without performing value
comparisons. If object1 and object2 both refer to the exact same object
instance, result is True; otherwise, result is False.
 IsNot Operator - It also compares two object reference variables and
determines if two object references refer to different objects. If object1 and
object2 both refer to the exact same object instance, result is False;
otherwise, result is True.
 Like Operator - It compares a string against a pattern.
BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR
VB.NET-UNIT-I

Logical/Bitwise Operators
Following table shows all the logical operators supported by VB.Net. Assume
variable A holds Boolean value True and variable B holds Boolean value False,
then:

Show Examples

Operator Description Example


It is the logical as well as bitwise AND operator.
If both the operands are true, then condition
And becomes true. This operator does not perform (A And B) is False.
short-circuiting, i.e., it evaluates both the
expressions.
It is the logical as well as bitwise OR operator. If
any of the two operands is true, then condition
Or becomes true. This operator does not perform (A Or B) is True.
short-circuiting, i.e., it evaluates both the
expressions.
It is the logical as well as bitwise NOT operator.
Use to reverses the logical state of its operand. If Not(A And B) is
Not
a condition is true, then Logical NOT operator True.
will make false.
It is the logical as well as bitwise Logical
Exclusive OR operator. It returns True if both
expressions are True or both expressions are
Xor False; otherwise it returns False. This operator A Xor B is True.
does not perform short-circuiting, it always
evaluates both expressions and there is no short-
circuiting counterpart of this operator.
It is the logical AND operator. It works only on (A AndAlso B) is
AndAlso
Boolean data. It performs short-circuiting. False.
It is the logical OR operator. It works only on
OrElse (A OrElse B) is True.
Boolean data. It performs short-circuiting.
IsFalse It determines whether an expression is False.
IsTrue It determines whether an expression is True.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Bit Shift Operators


We have already discussed the bitwise operators. The bit shift operators perform
the shift operations on binary values. Before coming into the bit shift operators, let
us understand the bit operations.

Bitwise operators work on bits and perform bit-by-bit operations. The truth tables
for &, |, and ^ are as follows:

P q p&q p|q p^q


0 0 0 0 0
0 1 0 1 1
1 1 1 1 0
1 0 0 1 1

Assume if A = 60; and B = 13; now in binary format they will be as follows:

A = 0011 1100

B = 0000 1101

-----------------

A&B = 0000 1100

A|B = 0011 1101

A^B = 0011 0001

~A = 1100 0011

We have seen that the Bitwise operators supported by VB.Net are And, Or, Xor
and Not. The Bit shift operators are >> and << for left shift and right shift,
respectively.

Assume that the variable A holds 60 and variable B holds 13, then:

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Show Examples

Operator Description Example


Bitwise AND Operator copies a bit to the (A AND B) will give 12,
And
result if it exists in both operands. which is 0000 1100
Binary OR Operator copies a bit if it exists
(A Or B) will give 61,
Or
in either operand. which is 0011 1101
Binary XOR Operator copies the bit if it is(A Xor B) will give 49,
Xor
set in one operand but not both. which is 0011 0001
(Not A ) will give -61,
Binary Ones Complement Operator is unary which is 1100 0011 in 2's
Not
and has the effect of 'flipping' bits. complement form due to a
signed binary number.
Binary Left Shift Operator. The left
A << 2 will give 240,
<< operands value is moved left by the number
which is 1111 0000
of bits specified by the right operand.
Binary Right Shift Operator. The left
operands value is moved right by the A >> 2 will give 15, which
>>
number of bits specified by the right is 0000 1111
operand.

Assignment Operators
There are following assignment operators supported by VB.Net:

Show Examples

Operator Description Example


Simple assignment operator, Assigns values C = A + B will assign
=
from right side operands to left side operand value of A + B into C
Add AND assignment operator, It adds right
C += A is equivalent to
+= operand to the left operand and assigns the
C=C+A
result to left operand
Subtract AND assignment operator, It
C -= A is equivalent to C
-= subtracts right operand from the left operand
=C–A
and assigns the result to left operand
Multiply AND assignment operator, It C *= A is equivalent to
*=
multiplies right operand with the left operand C=C*A

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

and assigns the result to left operand


Divide AND assignment operator, It divides
left operand with the right operand and assigns C /= A is equivalent to C
/=
the result to left operand (floating point =C/A
division)
Divide AND assignment operator, It divides
C \= A is equivalent to C
\= left operand with the right operand and assigns
= C \A
the result to left operand (Integer division)
Exponentiation and assignment operator. It
C^=A is equivalent to C
^= raises the left operand to the power of the right
=C^A
operand and assigns the result to left operand.
C <<= 2 is same as C =
<<= Left shift AND assignment operator
C << 2
C >>= 2 is same as C =
>>= Right shift AND assignment operator
C >> 2
Concatenates a String expression to a String Str1 &= Str2 is same as
&= variable or property and assigns the result to
the variable or property. Str1 = Str1 & Str2

Miscellaneous Operators
There are few other important operators supported by VB.Net.

Show Examples

Operator Description Example


Returns the address of a AddHandler Button1.Click,
AddressOf
procedure. AddressOf Button1_Click
It is applied to an operand in an
asynchronous method or Dim result As res
Await lambda expression to suspend = Await
execution of the method until AsyncMethodThatReturnsResult()
the awaited task completes. Await AsyncMethod()
It returns a Type object for the
specified type. The Type object
GetType MsgBox(GetType(Integer).ToString())
provides information about the
type such as its properties,

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

methods, and events.


Dim add5 = Function(num As
It declares the parameters and
Function Integer) num + 5
code that define a function
Expression 'prints 10
lambda expression.
Console.WriteLine(add5(5))
It uses short-circuit evaluation
to conditionally return one of Dim num = 5
If two values. The If operator can Console.WriteLine(If(num >= 0,
be called with three arguments "Positive", "Negative"))
or with two arguments.

Operators Precedence in VB.Net


Operator precedence determines the grouping of terms in an expression. This
affects how an expression is evaluated. Certain operators have higher precedence
than others; for example, the multiplication operator has higher precedence than
the addition operator:

For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator *


has higher precedence than +, so it first gets multiplied with 3*2 and then adds into
7.Here, operators with the highest precedence appear at the top of the table, those
with the lowest appear at the bottom. Within an expression, higher precedence
operators will be evaluated first.

Show Examples

Operator Precedence
Await Highest
Exponentiation (^)
Unary identity and negation (+, -)
Multiplication and floating-point division (*, /)
Integer division (\)
Modulus arithmetic (Mod)
Addition and subtraction (+, -)
Arithmetic bit shift (<<, >>)
All comparison operators (=, <>, <, <=, >, >=, Is,
IsNot, Like, TypeOf...Is)

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR


VB.NET-UNIT-I

Negation (Not)
Conjunction (And, AndAlso)
Inclusive disjunction (Or, OrElse)
Exclusive disjunction (Xor) Lowest

 Evaluation of Expressions
Expression is the combination of operator and operands. When you put the
operator in between the two operant then make a expression. when you evaluate an
expression it can be evaluated by using operator Precedence The end result of an
expression represents a value, which is typically of a familiar data type such as
Boolean, String, or a numeric type.

Several operators can perform actions in a single expression or statement, as


the following example illustrates.

5+4

' The preceding expression evaluates to 9.

15 * System.Math.Sqrt(9) + x

' The preceding expression evaluates to 45 plus the value of x.

"Concat" & "ena" & "tion"

' The preceding expression evaluates to "Concatenation".

763 < 23

' The preceding expression evaluates to False.

BCA-II(SEM-IV)BY Prof. A.D.CHAVAN SIR

You might also like