3. Introduction
More than three years ago, the Microsoft Visual Basic team set out to create
Visual Basic .NET. At that time managers would kid the development team by
saying that they were making only three “simple” changes to Visual Basic 6: a
new runtime system, a new development environment, and a new compiler.
The Visual Basic development team spent the next three years working on
one of these changes: the new compiler. Two other teams provided the
development environment and runtime. As we pointed out in Chapter 1, the
end result is not a new version of Visual Basic 6 but an entirely new product:
Microsoft Visual Basic .NET. The name is important for two reasons. First,
Visual Basic is still Visual Basic. Second, Visual Basic .NET is not Visual Basic 7.
5/21/2015 3
4. Visual Basic
Visual Basic (also termed Visual Basic.NET or VB) is a major
revision of earlier Microsoft VB products.
· This latest version is Version 10 of VB.
· This is an upgrade of earlier.NET versions.
· The current and earlier versions are not completely
compatible—a program coded with an earlier version that is
upgraded to the current version cannot be opened again with
the earlier version software.
· Version 6 and earlier are not .NET-compatible – programs
created with these versions are completely incompatible with
.NET applications.
5/21/2015 4
5. .NET Framework
The .NET Framework is composed of two general parts: the
common language runtime and the Framework class library.
The runtime is the foundation upon which the .NET
Framework is based. It provides the basic services on which
all .NET applications depend: code execution, memory
management, thread management and code security. The
Framework class library provides building blocks for
creating a variety of .NET applications, components, and
services.
5/21/2015 5
6. Overview
VB6 and VB.NET:
The VB6 and VB.NET transcend the languages. VB.NET is part of a
brand new platform, based on the .NET Framework. All languages in
.NET are based on this new platform, which allows many great new
capabilities for a VB developer. Because the .NET Framework is fully
object-oriented, .NET languages also must support OO features. The
result is that VB.NET is fully object-oriented. This is a huge difference
and is a powerful improvement over previous version of VB. It also
introduces another level of complexity along with this new power.
In many ways, VB.NET can be seen as an entirely new language. Oh,
much of the syntax is still there, and yes, much of it has changed. But
the real differences in VB.NET are in the way we accomplish various
tasks. Everything is done through the .NET Framework. All .NET
languages use the same .NET classes - C#, VB, COBOL, J#, etc.
5/21/2015 6
7. Overview(con’t…)
The greatest change in VB6 and VB.NET is of runtime
environment. VB6 used the VB-Runtime while VB.NET uses
the .Net Common Language Runtime (.Net CLR). The CLR is
much better designed and implemented than VB-Runtime.
The CLR uses better code translation through Just in Time
compiler while VB-Runtime interprets the code. The CLR
Garbage Collector is also more efficient than VB6 one as it
may detect cyclic references too.
VB6 was interpreter based language while VB.NET is a
compiled language VB6 was not a type-safe language while
VB.NET is a type safe language.
5/21/2015 7
8. There are a lot of differences:
Inheritance
Exception Handling
Overloading
Overriding Properties and Methods
Constructors and Destructors
Data Types
Interfaces
Delegates
Namespaces
Attributes
Shared Members
Multithreading
Memory Management
For detail check the down notes section
5/21/2015 8
10. VB6 vs VB.NET
VB 6 programs require significant modification to run
under VB .NET
VB6 was interpreter based language while VB.NET is a
compiled language
The greatest change in VB6 and VB.NET is of runtime
environment. VB6 used the VB-Runtime while VB .NET
adheres to the Common Language Specification (CLS) for
language interoperability which is also shared with C#.
VB 4, 5, and 6 were backward compatible VB .NET is not
backward compatible
VB6 was not a type-safe language while VB.NET is a type
safe language. There is no variant type in VB.NET and no
type conversions happen automatically in VB.NET
5/21/2015 10
11. A lot of code (like user interface code) in VB6 was
hidden from developer. In VB.NET no code is hidden
from developer and you can access and control each
part of your application and it now has C-like Syntax
VB .NET is now has object oriented programming
features
Arrays is 0 based in VB .NET. i.e when you declare an
array in vb6 "Dim Items(5) As String" you would get an
array with 6 elements but in VB.NET it would be 5
items now.
5/21/2015 11
12. VB2008.NET VB6 Difference
Short Integer 16 Bit
Integer Long 32 Bit
Long 64 Bit
Object Variant
Variant Dropped use the
new Object Data Type
Decimal
String String
No Fixed Length String
in Vb.NET
Currency
Use Decimal or long in
vb2008
5/21/2015 12
No More Variant, Currency Data Types in VB.NET, you also get the new
data types in Visual Basic. NET called Object other changes are as follow.
13. VB6 was only considered good for desktop windows
application. In VB.NET you can develop web applications,
distributed applications, create .NET windows and web
controls and components, write windows and web services.
In VB.NET, you can also use reflections to read the meta-
data of types and using reflection emit you can also
generate code to define and invoke types at runtime.
VB.NET uses .NET framework class library along with
specialized VB library (System.VisualBasic) as a standard
library. As a result, the standard library for VB.NET is much
enhanced and useful compared to VB6 standard library
5/21/2015 13
14. VB.NET is platform independent because of .Net framework.
Programs written in VB.NET can run on any platform where
.Net framework is present. The platform include both
hardware and software (operating system) platforms.
VB.NET also supports language interoperability with various
.NET compliant languages. This means that you can use and
enhance the code written in other .NET compliant languages.
Similarly the code written in VB.NET can also be used and
enhanced by other .NET compliant languages. Although VB6
also provided this functionality through COM but it was limited
and difficult to use and manage.
5/21/2015 14
15. VB.Net makes it easier because of the presence of
Intermediate Language (IL) and Common Language
Specification (CLS) of the .NET architecture.
VB6 uses COM (Component Object Model) as component
architecture. VB.NET uses assemblies as its component
architecture.
The Assemblies architecture has removed a lot of
problems with COM including DLL-Hell and versioning
problem.
Components created in VB6 (COM) need to make and
update registry entries. VB.NET does not require any
registry entry making the deployment easier.
5/21/2015 15
16. Since VB.NET is a natural evolution of VB - and
indeed its replacement .
5/21/2015 16
17. Conclusion
As we can see, quite a bit is involved in the three “simple”
changes that the teams made to create Visual Basic .NET.
Despite all of these changes, you should find the
development environment, compiler, and language familiar.
The skills that you have acquired using Visual Basic 6 are
not lost when you upgrade to Visual Basic .NET. The way
you create, run, and debug a Visual Basic .NET application is
nearly identical to the process you are already familiar with.
After all, Visual Basic is still Visual Basic. The spirit is alive
and well in Visual Basic .NET.
5/21/2015 17
Inheritance
VB.Net supports inheritance by allowing you to define classes that serve as the basis for derived classes. Derived classes inherit and can extend on the properties and methods of the base class. They can also override inherited methods with new implementations of the base class. All classes created with VB.Net are inheritable by default. Because the forms you design are really classes, you can use inheritance to define new forms based on existing ones. For details, see Inheritance in Visual Basic.
Exception Handling
VB.Net supports structured exception handling, using an enhanced version of the Try...Catch...Finally syntax supported by other languages such as C++. Structured exception handling combines a modern control structure (similar to Select Case or While) with exceptions, protected blocks of code, and filters. Structured exception handling makes it easy to create and maintain programs with robust, comprehensive error handlers. For details, see Introduction to Exception Handling.
Overloading
Overloading is the ability to define properties, methods, procedures, or operators that have the same name but use different data types. You can use overloaded procedures to provide as many implementations as necessary to handle different kinds of data, while giving the appearance of a single, versatile procedure. For details, see Overloaded Properties and Methods.
Overriding Properties and Methods
The Overrides keyword allows derived objects to override characteristics inherited from parent objects. Overridden members have the same arguments as the members inherited from the base class, but they have different implementations. A member's new implementation can call the original implementation in the parent class by preceding the member name with MyBase. For details, seeOverriding Properties and Methods.
Constructors and Destructors
Constructors are procedures that control initialization of new instances of a class. Conversely, destructors are methods that free system resources when a class leaves scope or is set to Nothing. VB.Net supports constructors and destructors using the Sub New and Sub Finalize procedures. For details, see Object Lifetime: How Objects Are Created and Destroyed.
Data Types
VB.Net introduces three new data types. The Char data type is an unsigned 16-bit quantity used to store Unicode characters. It is equivalent to the .NET Framework System.Char data type. The Short data type, a signed 16-bit integer, was named Integer in earlier versions of Visual Basic. The Decimal data type is a 96-bit signed integer scaled by a variable power of 10. In earlier versions of Visual Basic, it was available only within a Variant. In addition, Visual Basic now supports unsigned integer data types (UShort, UInteger, and ULong), as well as the signed type SByte. For details, see Data Types in Visual Basic.
Interfaces
Interfaces describe the properties and methods of classes, but unlike classes, interfaces do not provide implementations. Use the Interface statement to declare interfaces; use the Implements statement to write code that puts the items described in the interface into practice. For details, seeInterfaces in Visual Basic.
Delegates
Delegates are objects that can call the methods of objects on your behalf and are sometimes described as type-safe, object-oriented function pointers. You can use delegates to let procedures specify an event handler method that runs when an event occurs. You can also use delegates with multithreaded applications. For details, see Delegates and the AddressOf Operator.
Shared Members
Shared members are properties, procedures, and fields that are shared by all instances of a class. Shared data members are useful when multiple objects need to use information that is common to all objects. You can use shared class methods without first creating an object from a class. For details, see Shared Members in Visual Basic. References
You can use References to use objects defined in other assemblies. In VB.Net, references point to assemblies instead of type libraries. For details, see References and the Imports Statement.
Namespaces
Namespaces prevent naming conflicts by organizing classes, interfaces, and methods into hierarchies. For details, see Namespaces in Visual Basic.
Assemblies
Assemblies replace and extend the capabilities of type libraries by describing all the required files for a particular component or application. An assembly can contain one or more namespaces. For details, see Assemblies.
Attributes
You can use attributes to provide additional information about program elements. For example, you can use an attribute to specify which methods in a class should be exposed when the class is used as a XML Web service. For details, see Attributes in Visual Basic.
Multithreading
You can use VB.Net to write applications that can perform multiple tasks independently. A task that can hold up other tasks can execute on a separate thread, a process known as multithreading. By causing complicated tasks to run on threads that are separate from your user interface, multithreading makes your applications more responsive to user input. For details, see Multithreaded Applications.