lecture 1
lecture 1
NET
1
What is Visual Basic?
2
Cont’d
The overall approach to VB
programming is two fold
Creating user interface
appropriate for the specific
application
Adding instructions to carry out
the actions associated with
controls
3
Procedural, Object oriented
and Event driven programming
Procedural Language
12
Continued
When you run the application, that IL code
is translated into the binary code your
computer can understand by some special
compilers built into the CLR.
Compilers translate your code into
something that your machine's hardware,
or other software, can deal with directly. In
this way, Microsoft can one day create a
CLR for operating systems other than
Windows, and
your VB .NET applications, compiled into
IL, will run on them.
13
The .NET Framework class library
is the second major part of the .NET framework.
The class library holds an immense amount of
prewritten code that all the applications you create
with Visual Basic, Visual C++, C#, and other Visual
Studio languages build on.
The class library gives your program the support it
needs-for example, your program may create several
forms, and as there is a class for forms in the class
library, your program doesn't have to perform all the
details of creating those forms from scratch.
All your code has to do is declare a new form, and
the CLR compilers can get the actual code that
supports forms from the .NET Framework class
library.
In this way, your programs can be very small
compared to earlier Windows applications; because
you can rely on the millions of lines of code already
written in the class library, not everything has to be 14
continued
The code for all elements we use in a
VB .NET application-forms, buttons,
menus, and all the rest-all comes from the
class library.
Other Visual Studio applications use the
same class library, making it easy to mix
languages in your programming, even in
the same application.
Distributing applications is easier,
because all the support you need is
already on the machine you're installing
your application to.
15
Namespaces
.NET framework organizes its
classes into namespaces.
For example, the .NET framework
includes the namespaces
Microsoft.VisualBasic,
Microsoft.JScript,
Microsoft.CSharp, and
Microsoft.Win32.
16
Continued
In fact, these namespaces
contain relatively few classes
Real way we'll interact with
the .NET framework class library
in this course is through the
System namespace
17
System Namespaces
You can't build a VB .NET application without
using classes from the .NET System
namespace, as we'll see over and over again
in this course.
When you want to use a Windows form, for
example, you must use the
System.Windows.Forms. Form class. A
button in a Windows form comes from the
System.Windows. Forms.Button class, and
so on. There are many such classes, organized
into various namespaces like
System.Windows.Forms. Here's an
overview of some of those namespaces:
18
Continued
A button in a Windows form
comes from the
System.Windows.
Forms.Button class
and so on.
There are many such classes,
organized into various
namespaces like
System.Windows.Forms.
19
Here's an overview of some of
those namespaces
System-Includes essential classes and base
classes that define commonly used data
types, events and event handlers, interfaces,
attributes, exceptions, and so on.
System.Collections-Includes interfaces and
classes that define various collections of
objects, including such collections as lists,
queues, arrays, hash tables, and dictionaries.
System.Data-Includes classes that make up
ADO.NET. ADO.NET lets you build data-
handling components that manage data from
multiple distributed data sources. 20
Continued
System.Data.OleDb-Includes classes
that support the OLE DB .NET data
provider.
System.Data.SqlClient-Includes classes
that support the SQL Server .NET data
provider.
System.Diagnostics-Includes classes
that allow you to debug your application
and to step through your code. Also
includes code to start system processes,
read and write to event logs, and monitor
system performance.
21
Continued
System.Drawing-Provides
access to the GDI+ graphics
packages that give you access to
drawing methods.
System.Drawing.Drawing2D-
Includes classes that support
advanced two-dimensional and
vector graphics.
System.Drawing.Imaging-
Includes classes that support
22
Continued
System.Drawing.Printing-Includes classes
that allow you to customize and perform
printing.
System.Drawing.Text-Includes classes that
support advanced GDI+ typography operations.
The classes in this namespace allow users to
create and use collections of fonts.
System.Globalization-Includes classes that
specify culture-related information, including
the language, the country/region, calendars, the
format patterns for dates, currency and
numbers, the sort order for strings, and so on.
23
Continued
System.IO-Includes types that support
synchronous and asynchronous reading
from and writing to both data streams and
files.
System.Net-Provides an interface to many
of the protocols used on the Internet.
System.Net.Sockets-Includes classes
that support the Windows Sockets
interface. If you've worked with the
Winsock API, you should be able to develop
applications using the Socket class.
24
Continued
System.Reflection-Includes classes
and interfaces that return information
about types, methods, and fields, and
also have the ability to dynamically
create and invoke types.
System.Security-Includes classes that
support the structure of the common
language runtime security system.
System.Threading-Includes classes
and interfaces that enable
multithreaded programming.
25
Continued
System.Web-Includes classes and interfaces
that support browser/server communication.
Included in this namespace are the
HTTPRequest class that provides information
about HTTP requests, the HTTPResponse
class that manages HTTP output to the client,
and the HTTPServerUtility class that
provides access to server-side utilities and
processes. You can also use cookies, support
file transfer, and more with these classes.
System.Web.Security-Includes classes that
are used to implement ASP.NET security in
Web server applications. 26
Continued
System.Web.Services-Includes classes
that let you build and use Web services,
programmable entities on Web Server that
code can communicate with using
standard Internet protocols.
System.Windows.Forms-Includes
classes for creating Windows-based forms
that make use of the user interface
controls and other features available in
the Windows operating system.
System.Xml-Includes classes that
support processing of XML
27
File Extensions Used in VB .NET
32
Switching debug to
release
When you create a new solution,
Visual Basic creates it in debug
mode, meaning that you launch it
from the Debug menu as we've
been doing.
However, you can switch to
release mode in several ways
(like many things in VB .NET,
there's more than one way to do
it)
33
Ways to switch debug to
release
Select the Configuration Manager item in
the Build menu, then select Release in the
Active Solution Configuration list box and
click OK.
Select the solution you want to set the
mode for by clicking it in the Solution
Explorer, and find its Active Config
property in the properties window. When
you click the right-hand column in the
properties window next to this property, a
drop-down list box will appear; select
Release in that list box.
34
Continued
Select the solution you want to set the mode for by
clicking it in the Solution Explorer, and select the
Properties item in the Project menu, opening the
solution's property pages. Select the Configuration
Properties folder in the box at left, and the
Configuration item in that folder. Then select Release
from the drop-down list box in the configuration
column of the table that appears, and click OK.
Probably the easiest way to set the solution mode to
release or debug is simply to use the drop-down list
box that appears in the Visual Basic .NET standard
toolbar, at the top of the IDE. When you create a
new solution or project, this list box displays the
word Debug, and all you need to do to switch to
release mode is to select Release instead.
35
Building release
When you've set the mode for a solution
to Release, you build it using the Build
menu's Build item (the Build menu item
causes Visual Basic to compile only items
it thinks have been newly changed; to
force it to compile all items in the
solution, choose the Rebuild All item
instead of Build).
This builds the solution in a way that
others can use it, and you can deploy
your program this way
36
Visual Basic Integrated Development
Environment
37
Continued
There are so many independent windows in
the IDE that it's easy to misplace or rearrange
them inadvertently.
The IDE windows are docking windows, which
means you can use the mouse to move
windows around as you like
when the windows are near an edge, they'll
"dock"-adhere-to that edge
you can reconfigure the IDE windows as you
like. If you move IDE windows inadvertently,
don't panic; just use the mouse to move them
back.
38
Continued
windows in the IDE come with an X button
at upper left, which means you can close
them. I
don't know about you, but I sometimes click
these when I don't mean to, and a window I
wanted disappears.
It's easy to panic: The toolbox is gone! I'll
have to reinstall everything! In fact, all you
have to do is to find that window in the
View menu again (such as View|Toolbox) to
make it reappear.
39
Continued
There's so much packed into the IDE that
Microsoft has started to make windows share
space
you can keep them separate using tabs such
as those you can see above the form at the
center of Fig: 1. If you click the
Form1.vb[Design] tab, you see the form itself
as it'll appear when the program runs;
if you click the Form1.vb tab, you'll see the
form's code, and
if you click the Start Page tab, you'll see the
Start page, which lets you select from among
recent solutions to open. 40
Continued
VB .NET adds a new button in dock able IDE
windows-a little thumbtack button at upper
right as you see in various windows in Fig:
1 next to the X close button.
This is the "auto-hide" feature, which lets
you reduce a window to a tab connected to
the edge it's docked on.
If I let the mouse move over that tab, the
full Sever Explorer window will glide open,
covering most of the toolbox.
You can auto-hide most windows like this
To restore a window to stay-open status,
just click the thumbtack again. 41
Continued
you can customize the IDE as well.
For example, to customize IDE options
such as the fonts and colors used to
display code, you select the Tools|
Options menu item and use the various
items in the Environment folder.
To customize menus and toolbars, such
as specifying the toolbars to display
(How many are there to choose from?
Twenty-seven.), or what buttons go on
what toolbars, use the Tools|Customize
menu item.
42
Thank you!!!
43