Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
96 views

Lecture 3 - Programming With VB

The document discusses the history of Visual Basic .NET (VB.NET) and the .NET framework. VB.NET was released in 2002 as the successor to Visual Basic 6.0 and relies on the .NET framework. The .NET framework is a software development platform developed by Microsoft that allows creation of a wide range of applications across different operating systems using languages like C# and VB.NET. It has evolved from only supporting Windows to being cross-platform with the release of .NET Core.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views

Lecture 3 - Programming With VB

The document discusses the history of Visual Basic .NET (VB.NET) and the .NET framework. VB.NET was released in 2002 as the successor to Visual Basic 6.0 and relies on the .NET framework. The .NET framework is a software development platform developed by Microsoft that allows creation of a wide range of applications across different operating systems using languages like C# and VB.NET. It has evolved from only supporting Windows to being cross-platform with the release of .NET Core.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

OBJECT ORIENTED PROGRAMMING

USING VB.NET

By:
Collinson Colin Agbesi

Recommended Textbooks
1. Mike Snell & Lars Powers; “Microsoft Visual Studio 2010
Unleash” Pearson Education, Inc.
2. Evangelos Petroutsos, “Mastering Microsoft Visual Basic
2010”, Wiley Publishing Inc.
HISTORY OF VB.NET

 The history of Visual Basic dates back in the 1980s. But


before Visual Basic there was earlier versions such as
GWBASIC, BASICA, BASIC, QBASIC etc.

 BASIC stands for Beginners All-Purpose Symbolic


Instruction Code. BASIC is a family of general-purpose,
high-level programming languages whose design
philosophy emphasizes ease of use. The original version
of BASIC was designed by John G. Kemeny and Thomas
E. Kurtz and released at Dartmouth College in 1964.

 QBASIC stands for Quick Beginners All-Purpose


Symbolic Instruction Code (Quick BASIC). QBasic was
developed as a replacement for GW-BASIC. GW-BASIC is
a dialect of the BASIC programming language developed
HISTORY OF VB.NET

 Visual Basic is a third-generation event-driven


programming language from Microsoft derived from the
Beginners All-Purpose Symbolic Instruction Code
(BASIC). Visual Basic 1.0 was introduced in 1991 by
Microsoft for their Windows Operating System. The drag
and drop design for creating the user interface in VB is
derived from a prototype form generator developed by
Alan Cooper and his company called Tripod.
 In 1988, Alan Cooper, who is known as the 'father' of
Visual Basic, shows a drag-and-drop shell prototype
called Tripod to Bill Gates the founder of Microsoft.
Microsoft negotiates to buy the concept, now code-
named Ruby. The Tool includes a widget control box, the
ability to add widgets dynamically, and a small language
engine. Microsoft decided to combine Ruby with the
Basic language to create Visual Basic.
HISTORY OF VB.NET

Version Date Released Operating System Description


 Visual Basic This version was first released at the Comdex/Windows World trade show in Atlanta,
May 1991 Windows
1.0 Georgia.

This version of the language itself was not quite compatible with Visual Basic for Windows.
Visual Basic
September 1992 DOS This was because the language was actually the next version of Microsoft's DOS-based
1.0
BASIC compilers, QuickBASIC and BASIC Professional Development System.

The programming environment was easier to use than the 1.0 version, and it was more fast.
Visual Basic
November 1992 Windows Notably, forms became instantiable objects, thus laying the founding concepts of class
2.0
modules as were later offered in version 4.0.

Visual Basic Visual Basic 3.0 came in Standard and Professional versions. VB3 included version 1.1 of
Summer 1993 Windows
3.0 the Microsoft Jet Database Engine that could read and write Jet (or Access) 1.x databases.

This was the first version that can create 32-bit applications as well as 16-bit Windows
Visual Basic
August 1995 Windows programs. It has three editions; Standard, Professional, and Enterprise. It also introduced the
4.0
ability to write non-GUI classes in Visual Basic.

This version was released exclusively for 32-bit versions of Windows. Programmers who
Visual Basic preferred to write 16-bit programs were able to import programs written in Visual Basic 4.0
February 1997 Windows
5.0 to Visual Basic 5.0, and Visual Basic 5.0 programs can easily be converted with Visual
Basic 4.0

This version improved in a number of areas including the ability to create web-based
Visual Basic applications. VB6 entered Microsoft's "non-supported phase" as of March 2008. Although
Mid 1998 Windows
6.0 the Visual Basic 6.0 development environment is no longer supported, the runtime is
supported on Windows Vista, Windows Server 2008 and Windows 7.
HISTORY OF VB.NET

 Visual Basic .NET (VB.NET) is a multi-paradigm,


object-oriented programming language, implemented on
the .NET Framework. VB.NET is a programming language
developed by Microsoft. Microsoft launched VB.NET in
2002 as the successor to its original Visual Basic
language. It was first released to replace Visual Basic 6.
VB.NET is an object-oriented programming language.
This means that it supports the features of object-
oriented programming which include encapsulation,
polymorphism, abstraction, and inheritance.

 Microsoft's integrated development environment (IDE)


for developing in Visual Basic .NET language is Visual
Studio. Most Visual Studio editions are commercial; the
only exceptions are Visual Studio Express and Visual
Studio Community, which are freeware.
HISTORY OF VB.NET

 The language was designed in such a way that it is easy


to understand to both novice and advanced
programmers. Since VB.NET relies on the .NET
framework, programs written in the language run with
much reliability and scalability. The .NET Framework
SDK includes a command-line compiler called vbc.exe.
 With VB.NET, you can create applications that are fully
object-oriented, similar to the ones created in other
languages like C++, Java, or C#. Programs written in
VB.NET can also interoperate well with programs written
in Visual C++, Visual C#, and Visual J#. VB.NET treats
everything as an object.
 Also VB.NET is an evolved version of Visual Basic 6, but
it's not compatible with it. If you write your code in
Visual Basic 6, you cannot compile it under VB.NET.
HISTORY OF VB.NET

 VB.NET Releases
Version Date Released Description

VB.NET 7.0 2002 The first version, Visual Basic .NET, relies on .NET Framework 1.0

VB.NET 7.1 2003 Visual Basic .NET 2003 was released with .NET Framework 1.1

VB.NET 8.0 2005 Microsoft dropped ".NET" from the name of the product, calling the next
version Visual Basic 2005.
VB.NET 9.0 2008 Visual Basic 9.0 was released along with .NET Framework 3.5

VB.NET 10.0 2010 Microsoft had planned to use Dynamic Language Runtime (DLR) for that
release but shifted to a co-evolution strategy between Visual Basic and
C# to bring both languages into closer parity with one another.
VB.NET 11.0 2012 Visual Basic 2012 was released along .NET Framework 4.5

VB.NET 12.0 2013 Visual Basic 2013 was released along .NET Framework 4.5.1 with Visual
Studio 2013
VB.NET 14.0 2015 Visual Basic 2015 (code named VB "14.0") has been released with
Visual Studio 2015
VB.NET 15.0 2017 Visual Basic 2017 (code named VB "15.0") has been released with
Visual Studio 2017
VB.NET 16.0 2019 Visual Basic 2019 (code named VB "16.0") has been released with
Visual Studio 2019
HISTORY OF VB.NET

 THE .NET FRAMEWORK


 The .Net framework (pronounced dot net) is a software
development platform developed by Microsoft. The
framework was meant to create applications, which
would run on the Windows Platform. The first version of
the .Net framework, that is .Net framework 1.0 was
released in the year 2002. The .Net framework has come
a long way since then, and the current version is 4.8
 The .Net framework can be used to create both Form-
based and Web-based applications. Web services can
also be developed using the .Net framework.
 The framework also supports various programming
languages such as Visual Basic and C#, VB.NET, C++
and F#. So developers can choose and select the
language to develop the required application.
HISTORY OF VB.NET

 THE .NET FRAMEWORK


 The .NET framework is a structure that provides a
programming guidelines that can be used to develop a
wide range of applications from web to mobile to
Windows-based applications. The .NET framework was
originally developed for only Windows environment but it
is now cross platform. It can be used to develop apps
for other operating environments and platforms.

 The .NET Core, a set of tools consisting of the runtime,


library and compiler components, can create apps that
run on Windows, Mac OS X, Linux, iOS, Android etc. The
.NET Core runtime, libraries, and compiler are all open
source on GitHub and are taking contributions. Several
parts of .NET were made available under open source
licenses, meaning any developer can contribute to it.
HISTORY OF VB.NET

 .NET FRAMEWORK VERSIONS


Version Date Description
Released
.NET 1.0 February, The first version of the .NET Framework released for Windows 98, ME, NT, 4.0, 2000 & XP
2002
.NET 1.1 April, 2003 Version 1.1 is the first minor upgrade of .NET Framework.

.NET 2.0 January, Version 2.0 was released along with Visual Studio 2005, Microsoft SQL Server 2005, and BizTalk 2006. .NET Framework 2.0 is
supported on Windows 98, ME, 2000, XP, Server 2003, Vista, Server 2008, and Server 2008 R2
2006
.NET 3.0 November, .NET Framework 3.0, was formerly called WinFX. It includes a new set of managed code APIs that are an integral part of
Windows Vista and Windows Server 2008. It is also available for Windows XP SP2 and Windows Server 2003
2006
.NET 3.5 November, As with .NET Framework 3.0, version 3.5 uses Common Language Runtime (CLR) 2.0, that is, the same version as .NET
Framework version 2.0.
2007
.NET 4.0 April, 2010 .NET framework 4.0 was developed for parallel extensions to support parallel computing, VB.NET, C#, common runtime language
4.0. .NET Framework 4.0 is supported on Windows XP (with Service Pack 3), Windows Server 2003, Vista, Server 2008, 7 and
Server 2008 R2.

.NET 4.5 August, .NET Framework 4.5 includes a set of new or improved features The .NET Framework 4.5 is only supported on Windows Vista or
later. The .NET Framework 4.5 uses Common Language Runtime 4.0, with some additional runtime features. .Net Framework
2012
4.5.1 was released October, 2013 and .Net Framework 4.5.2 was released May, 2014

.NET 4.6 July, 2015 .NET Framework 4.6 supports a new just-in-time compiler (JIT) for 64-bit systems called RyuJIT, which features higher
performance and support for SSE2 and AVX2 instruction sets. .NET framework 4.6.1 was released November 2015 and .NET
framework 4.6.2 is released August, 2016

.NET 4.7 April, 2017 Microsoft announced that .NET Framework 4.7 was integrated into Windows 10 Creators Update, promising a standalone installer
for other Windows versions. .NET framework 4.7.1 was released October, 2017 and .NET framework 4.7.2 was released April,
2018

.NET 4.8 April, 2019 .NET Framework includes additional enhancements for high-resolution displays, performance updates, and security
enhancements. .NET Framework 4.8 is supported on Windows 7, Server 2008 R2, Server 2012, 8.1, Server 2012 R2, 10, Server
2016 and Server 2019
HISTORY OF VB.NET

 .NET FRAMEWORK ARCHITECTURE


 The architecture of the .Net framework is based on the
following key components; Common Language Runtime
and the .NET Framework Class Library.

 The basic architecture of the .Net framework comprises;

 Common Language Runtime

 .NET Framework Class Library

 .NET Framework Language


HISTORY OF VB.NET

 .NET FRAMEWORK ARCHITECTURE


HISTORY OF VB.NET

 .NET FRAMEWORK COMPONENTS


 Common Runtime Language: The common language
runtime is the foundation of .NET Framework. It is a
runtime agent that manages code at execution time,
providing core services such as memory management,
thread management, and remoting, while also enforcing
strict type safety and other forms of code accuracy that
promote security and robustness.
 The Common Language Infrastructure or CLI is a
platform on which the .Net programs are executed.
 The CLI has the following key features:
 Exception Handling - Exceptions are errors which occur when the
application is executed.
 Garbage Collection - Garbage collection is the process of removing
unwanted resources when they are no longer required.
 Working with Various programming languages
HISTORY OF VB.NET

 .NET FRAMEWORK COMPONENTS


 Hierarchy of Components: .NET framework supports
multiple programming languages so you can develop apps in
various .Net programming languages. The .NET component
levels, layers and hierarchy are as follows;

 Language - The first level is the programming language itself,


the most common ones are VB.Net and C# etc.
 Compiler – This is the second level. There is a separate
compiler for each programming language. So for VB.Net
language, there will be a separate VB.Net compiler. Similarly,
for C#, you will have a C# compiler etc.
 Common Language Interpreter – This is the final layer in
.Net which would be used to run a .net program developed in
any programming language. So the subsequent compiler will
send the program to the CLI layer to run the .Net application.
HISTORY OF VB.NET

 .NET FRAMEWORK COMPONENTS


HISTORY OF VB.NET

 .NET FRAMEWORK COMPONENTS


 .NET Framework Class Library: The .NET Framework
includes a set of standard class libraries. A class library
is a collection of methods and functions that can be used
for the core purpose. The class library is object oriented,
providing types from which your own managed code
derives functionality. Example, there is a class library
with methods to handle all file-level operations that is; a
method to read text from a file or write text to a file etc.

 Most of the methods are split into either the System.* or


Microsoft.* namespaces. The asterisk * is a reference to
all the methods that fall under the System or Microsoft
namespace. A namespace is a logical separation of
methods or storage for methods, files & resources etc
HISTORY OF VB.NET

 .NET FRAMEWORK COMPONENTS


 Languages: The .NET framework supports multiple
programming languages. Example includes; VB.Net, C#,
ASP.Net, F# etc. The types of applications that can be
built in the .Net framework is classified broadly into the
following categories.
 WinForms – This is used for developing Forms-based applications,
which would run on an end user machine. Notepad is an example
of a client-based application.
 ASP.Net – This is used for developing web-based applications,
which are made to run on any browser such as Internet Explorer,
Chrome or Firefox.
 ADO.Net – This technology is used to develop applications to
interact with Databases such as Oracle or Microsoft SQL Server.
 Microsoft always ensures that .Net frameworks are in
compliance with all supported Windows operating
systems and other supported platforms.
HISTORY OF VB.NET

 .NET FRAMEWORK COMPONENTS


 Applications: You can use .NET Framework to develop the
following types of apps and services;

 Console applications
 Windows GUI apps or Windows Forms
 Windows Presentation Foundation (WPF) apps.
 ASP.NET applications
 Windows services
 Service-oriented apps using Windows Communication
Foundation (WCF)
 Workflow-enabled apps using Windows Workflow
Foundation (WF)

 The Windows Forms classes are a comprehensive set of


reusable types that vastly simplify Windows GUI development.
HISTORY OF VB.NET

 .NET FRAMEWORK COMPONENTS


 . NET Framework Principles: The following principles makes
it easy to develop .Net applications.
 Interoperability - The .Net framework provides a lot of backward
support.
 Portability - Applications built on the .Net framework can be
made to work on any Windows platform and other platforms, such
as Mac, Linux, iOS, Android etc.
 Security - The .NET Framework has a good security mechanism.
The inbuilt security mechanism helps in both validation and
verification of applications.
 Memory management - The Common Language runtime does all
the work of memory management. The .Net framework uses the
“Garbage Collector” to mange the resources which are not used by
a running program.
 Simplified deployment - The .Net framework also have tools,
which can be used to package applications built on the .Net
framework. These packages can then be distributed and installed
automatically on client machines.
HISTORY OF VB.NET

 ADVANTAGES OF VB.NET:
 Some merits / pros and benefits of VB.NET includes;
 Easy development and deployment of applications using rapid
application development and wizards etc
 Automatic formatting of codes and autocorrect features
 Object-oriented constructs to create an enterprise-class code
 Create web applications with modern features like performance
counters, event logs, file system using visual form designers.
 Drag and drop capability to replace any elements or items that
you may need.
 Connect applications to other applications created in languages
that run on the .NET framework.
 Additional features like docking, automatic control anchoring,
and in-place menu editor for developing web applications.
 Large talent pool and knowledge based means there are many
VB.NET programmers so you can easily find help on any
HISTORY OF VB.NET

 DISADVANTAGES OF VB.NET
 Some demerits / cons and drawbacks of VB.NET includes;
 Cannot handle pointers directly – This means more coding required
to handle a pointer. Additional coding results in additional CPU cycles;
which in turn requires additional processing time; which results in
slower applications. The application becomes slow.
 Intermediate Language (IL) compilation – These types of compilers
can be easily decompiled (a.k.a Reverse Engineered); there is little that can be
done to deter decompiling of the application, and nearly nothing that can be done
to prevent it.
 Just-In-Time (JIT) compiler – JIT compiling is the way the computer can
interpret the IL compilation. This is essential to running the application. This
means the target computer will be required to have JIT and that the application
can receive performance degradation because of the extra CPU cycles required to
use JIT.
Large Libraries – Because VB is an IL there is a large number of libraries
required for the JIT compiler to interpret the application. Large libraries require
more hard drive space, more computing time and most of all it can be a nuisance
if the application is being deployed over the internet and the user must obtain
these libraries in addition to the files of the compiled application.
HOW TO GET STARTED

 You need the following;


 A Personal computer with (display, memory, HDD, processor)
 A Compiler that suits your operating system (OS):
Compiler is a program that translates the source code of another
program written in high level language into a low level machine
language for the computer to understand and execute.
 Integrated Development Environments: An IDE is a software
development environment or platform that includes an Editor, Compiler
and Debugger in an integrated package that is distributed together to
facilitate and simplify coding and implementation of programming
languages. Some IDEs will require the user to make the integration of
the components themselves and others will do it automatically.
 A good IDE is one that permits the programmer to use it to perform
tasks and at the same time provide some tools for reading error and
debugging and managing the code.
 When selecting an IDE, remember that you are also investing time to
become proficient in its use, completeness, stability and portability
across different operating systems.
HOW TO GET STARTED

 VB.NET IDE, Compilers and OS Platforms:


 VB.NET is a Microsoft Windows application development
language. It is mainly a windows based programming
language but supports other operating systems such as;
Mac, Linux, iOS and Android etc.

 The main IDE for developing VB.NET applications is the


Microsoft Visual Studio. The Microsoft Visual Studio is
a commercial software but comes with free versions
thus; Microsoft Visual Studio Express or Microsoft
Community Edition.
 The most basic edition of Visual Studio, the Community
edition, is available free of charge. It is a free, fully-
featured IDE for students, open-source and individual
developers“.
STRUCTURE OF VB.NET PROGRAM
 Console Application 1

 The panel (in light blue) shows the source code for our first
program. The light blue numbers represent the line numbers
and are not part of the program but are shown for
informational purposes.
STRUCTURE OF VB.NET PROGRAM
 The previous program is the typical program that programmers
write for the first time, and its output is the displaying on the
PC screen the texts "Hello World”. It is one of the simplest
programs that can be written in C++, but it already contains
the fundamental components that every C++ program has. We
are going to look line by line at the code we have just written.

 „My first program in VB.NET


This is a comment line. Comments do not have any effect on
the behavior of the program. The programmer can use them to
give explanations or descriptions within the source code. In
this case, the line is a brief description of our program.
 Note: Comments are written using a single quotation mark in
VB.NET. Example „This is a comment
STRUCTURE OF VB.NET PROGRAM
 Imports System.Console
 In VB.NET, the System.* or Microsoft.* is a namespace
where some methods, functions and commands are kept. The
System.Console namespace contains some methods,
functions and commands which are used for writing console
applications.

 Example of these functions includes the Write(),


WriteLine(), Read() and ReadLine() functions. This would
also enable the programmer or user to perform input and
output functions at the console. Hence the statement Imports
System.Console in VB.NET is used to include the standard
input-output libraries and functions which would be used later
in the program.
STRUCTURE OF VB.NET PROGRAM
 Module Module1
 In VB.NET, console applications are defined as Modules.
Modules are similar to files in windows based applications.
Hence Module Module1 is a declaration of the first module
named Module1 in the console program. A console application
can have several modules within the same program. Every
module in VB.NET must end with the statement End Module.
STRUCTURE OF VB.NET PROGRAM

 Sub Main()
 This line corresponds to the beginning of the main function.
The main function is the point where all VB.NET programs start
their execution, independently of its location within the source
code. It does not matter whether there are other functions with
other names defined before or after it - the instructions
contained within the Main() function will always be the first
ones to be executed in any program. So it is very essential that
all VB.NET programs have a main function.

 The word main is followed in the code by a pair of parentheses


( ). That is because it is a function declaration. In VB.NET,
what differentiates a function declaration from other types of
expressions are these parentheses that follow its name. Often,
these parentheses may have a list of parameters within them.
 In VB.NET, the main function Sub Main() must end with the
statement End Sub.
STRUCTURE OF VB.NET PROGRAM
 Write("Hello World")
This line is a VB.NET statement. A statement is a simple or
compound expression that can actually execute. In fact, this
statement performs the only action that generates a visible
output in our first program.
 Write() is the name of the console output function in VB.NET,
and the meaning of the entire statement is to insert a
sequence of characters (in this case the Hello World sequence
of characters) into the standard output stream which usually
corresponds to the screen.

 Write() is declared in the System.Console standard library or


namespace, so that's why we needed to include that specific
file and to declare that we were going to use this specific
namespace earlier in our code.
STRUCTURE OF VB.NET PROGRAM

 Read() or ReadLine()
 The Read() or ReadLine() functions is used to accept input
from the user whenever the main function finishes it work. This
would prevent the output screen from disappearing after
execution of the program. The Read() or ReadLine() is used to
stop or pause the output screen after the program executes its
instructions. This is the most usual way to end a console
program in VB.NET console program. It is used to accept input
from the user. This command prevents the window from
closing after execution because the program still awaits an
input from the user.
 You may have noticed that not all the lines of this program
perform actions when the code is executed. Some lines contain
only comments. There were lines with directives for the
compiler's preprocessor to import the standard input-output
functions. Also there were lines that began the declaration of a
the main function and, finally lines with statements, which are
included within the body of the main function.
STRUCTURE OF VB.NET PROGRAM
 Console Application 2

 In VB.NET statements are written with the Write() or


WriteLine() functions at the console. We can write many
statements per line or write a single statement that takes
many lines. The above program has two statements but the
output is joined together because we used the Write() function.
STRUCTURE OF VB.NET PROGRAM
 Console Application 3

 The Write(“ ”) function can be used to carry a space to


separate two statements that we want to put on the same line.
In the previous example, the two statements are joined
together on one line. But in this example, the two statements
are place on one line but not joined together.
STRUCTURE OF VB.NET PROGRAM
 Console Application 4

 In VB.NET the WriteLine() function is used to put text on


separate lines at the console. We can write many statements
per line using the WriteLine() function. The above program has
two statements and the output is separated because we used
the WriteLine() function.
STRUCTURE OF VB.NET PROGRAM
 Console Application 5

 In VB.NET the WriteLine() function is used to put text on


separate lines at the console. We can write many statements
per line using the WriteLine() function. The above program has
two statements and the output is separated because we used
the WriteLine() function.
STRUCTURE OF VB.NET PROGRAM
 Console Application 6

 The WriteLine() function is used to put text on separate lines


at the console. We can put a WriteLine() function between two
statements to give a paragraph or space between them. The
above program has two statements and the output is
separated because we used the WriteLine() function.
STRUCTURE OF VB.NET PROGRAM
 Console Application 7

 The WriteLine() function is used to put text on separate lines


at the console. We can put a WriteLine() function between two
statements to give a paragraph or space between them. The
above program has two statements and the output is
separated because we used the WriteLine() function.
STRUCTURE OF VB.NET PROGRAM
 Console Application 8

 The WriteLine() function is used to put text on separate lines


at the console. We can put a WriteLine() function between two
statements to give a paragraph or space between them. The
above program has two statements and the output is
separated because we used the WriteLine() function.
THE END
 T o b e c o n t i n u e d………………………

You might also like