Thursday, July 24, 2008

VB6.0 vs. VB.NET

.NET Platform
To understand VB.NET, we must first understand the .NET platform.

 .NET Framework: a set of approximately 3500 classes.
 These classes are divided into namespaces that group similar classes together.
 For organization, each class belongs to only one namespace.
 Most classes are lumped into a name space called System

System.Data contains classes used for accessing data in a DB
System.XML contains classes used for reading/writing XML
System.Windows.Forms contains classed used for
System.Net contains classes for communicating over the network.

 Essentially MS performed a massive re-organization of all the classes, no longer leaving methods or functions without clearly belonging to a specific class. For example, note the difference between Messagebox() in VB6.0 and Messagebox.Show() in VB.NET (to be discussed later).

Visual Studio.NET
 Visual Studio.NET is the next version of IDE from MS.
Note: VS.NET does require at least double its system requirements to function feasibly.
Note: VS.NET can be installed on the same machine as VS 6.0. Many have warned against it, yet personal experience has proven otherwise.

 VS.NET comes standard with VB.NET, C# (C-Sharp), and VC++.

 VS.NET supports more than 20 languages.

 All languages compile to .EXE and .DLLs containing Common Intermediate Language (CIL or IL), not machine native code. C++ is the only exception offering an option to compile to machine native code.

 These CIL executables then run in the Common Language Runtime (CLR) using a Just-in-Time (JIT) compiler. Note the similarity of .NET to JAVA and JVM.

 The JIT compiler dynamically converts the IL to machine native code during execution, and caches the native code for subsequent use.
Advantages of CLR

 The JIT allows code to run in a protected environment as managed code. The protected environment polices each application to run in its own memory segment. This prevents a developer from shooting himself in the foot, but it also limits control.

 Using a JIT allows the IL code to be hardware independent. As long as the .NET framework is installed, the IL code can be executed.

 The CLR also allows for enforcement of code access security.

 Verification of type safety.

 Access to Metadata (enhanced Type Information)

 Support for developer services (profiling, debugging)

 Interoperation between managed code, COM objects, pre-existing DLLs (unmanaged code and data).
.NET components can access COM components.
COM components can access .NET components by registering the .Net assembly using the regasm.exe utility.

 .NET provides a unified Programming Model
Then: VB for RAD, VC++ for MFC/ATL, ASP for code embedded web pages
Now: Any language to handle any .NET functionality.

.NET Framework supports Web Standards
WSDL for Web Services

The IL can be modified using Intermediate Language Dis-assembler (ILDASM). ILDASM is a tool used to properly display IL in a human readable format. A developer can then add remove code as needed for fine tuning. Many developers speak highly of this method for fine tuning code.

Visual Studio.Net vs. Visual Studio 6.0
 Syntax of event handling methods:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 In VS.Net CTRL-ESC opens inteli-sense for easy searching of methods

 With VB6.0, project files were very simple:
.CLS / .FRM / .RES

 File structure in .NET varies greatly from VB6.0 file structure.

Note: For a tree diagram of the file structure, enter the following in a DOS prompt.
C:\>Tree C:\VBPrograms\WindowsApplication1 /F /A

| WindowsApplication1.vbproj
| AssemblyInfo.vb
| Form1.vb
| Form1.resx
| WindowsApplication1.vbproj.user
| WindowsApplication1.sln
| WindowsApplication1.exe
| WindowsApplication1.pdb
| WindowsApplication1.Form1.resources
| WindowsApplication1.pdb
| WindowsApplication1.exe

 Both .EXE are executable, pending the user has .NET framework installed.

 Use of “Imports System.IO” imports the System.IO. This is similar to the With block code.
Application Deployment
 Downloading code is also available.
 No need to register components.
 Can run multiple component versions simultaneously.

Your Title