What’s new in VB .NET

35
Visual Basic .NET Comprehensive Concepts and Techniques What’s new in VB .NET adapted from a presentation on Introduction to Visual Basic .NET by Jeff Quasney Course Technology

description

What’s new in VB .NET. adapted from a presentation on Introduction to Visual Basic .NET by Jeff Quasney Course Technology. An Overview. What’s New in Visual Studio .NET?. IDE (Start page, common for ALL .NET languages) Application templates New editing tools (HTML, XML, XSL, CSS…) - PowerPoint PPT Presentation

Transcript of What’s new in VB .NET

Page 1: What’s new in VB .NET

Visual Basic .NETComprehensive Concepts

and Techniques

What’s new in VB .NETadapted from a presentation on

Introduction to

Visual Basic .NET

by

Jeff Quasney

Course Technology

Page 2: What’s new in VB .NET

2Introduction to Visual Studio .NET

Page 3: What’s new in VB .NET

3Introduction to Visual Studio .NET

An Overview

Page 4: What’s new in VB .NET

4Introduction to Visual Studio .NET

What’s New in Visual Studio .NET?

• IDE (Start page, common for ALL .NET languages)

• Application templates• New editing tools (HTML, XML, XSL,

CSS…)• Cross-language debugging, Multiple

languages per “Solution”• New sample apps and documentation• Strong focus on XML

Page 5: What’s new in VB .NET

5Introduction to Visual Studio .NET

What’s New in Microsoft Visual Basic .NET?• VB .NET was a rewrite, not an update

• New/changed data types– No Variant, CTS

• New/changed syntax– Dim, assignment, arrays, keywords…

• Application distribution

Page 6: What’s new in VB .NET

6Introduction to Visual Studio .NET

What’s New in Microsoft Visual Basic .NET? (continued)• Inheritance• Exception handling (Structured exception

handling)• Overloading• Multithreading• Web development

– Web services– Web applications (ASP.NET)

• ADO.NET

Page 7: What’s new in VB .NET

7Introduction to Visual Studio .NET

Application Types

• Console Applications

Page 8: What’s new in VB .NET

8Introduction to Visual Studio .NET

Application Types

• Windows Applications

Page 9: What’s new in VB .NET

9Introduction to Visual Studio .NET

Application Types

• Windows Services

Page 10: What’s new in VB .NET

10Introduction to Visual Studio .NET

Application Types

• Web Applications

Page 11: What’s new in VB .NET

11Introduction to Visual Studio .NET

Application Types

• Web Services

Page 12: What’s new in VB .NET

12Introduction to Visual Studio .NET

Application Types

• Components

Page 13: What’s new in VB .NET

13Introduction to Visual Studio .NET

What is .NET?

Page 14: What’s new in VB .NET

14Introduction to Visual Studio .NET

.NET Framework

Page 15: What’s new in VB .NET

15Introduction to Visual Studio .NET

Why .NET?

• Common classes

• Common security model– DLL “H E double-toothpicks” gone?– Side-by-side execution

• Garbage collection

• Multi-platform?

• New application types

• Language interoperability

Page 16: What’s new in VB .NET

16Introduction to Visual Studio .NET

The Common Language Runtime

• Takes control of the application and runs the application under the operating system

• Microsoft Intermediate Language (MSIL)

Page 17: What’s new in VB .NET

17Introduction to Visual Studio .NET

The Common Language Runtime

• MSIL is CPU/OS independent

• Compile once for multiple CPU’s/platforms– Take an EXE and run it on Linux– Ximian (?) is working on this

• Assembly and manifest concept– Xcopy installs– Side-by-side execution– Logically, all EXEs and DLLs act as DLLs

Page 18: What’s new in VB .NET

18Introduction to Visual Studio .NET

The Common Language Runtime

• Registration info no longer in registry– Meta data stored in assemblies– Only distribute assembly

• .NET Framework required on user’s system

• Memory management• Exception handling• No IDL, no registration, no HRESULTS, no

GUIDs, • Replaces all COM plumbing

Page 19: What’s new in VB .NET

19Introduction to Visual Studio .NET

What’s New in VB .NET?

Page 20: What’s new in VB .NET

20Introduction to Visual Studio .NET

About Procedures• Subs and functions need parentheses

Use

MyProc(“A parameter”)

Not

MyProc “A parameter”

• ByVal is now the default!• Optional arguments need a default value

– Sub DoWork(Optional ByVal i As Integer = 1)

• Return is used in Functions to return a value

Page 21: What’s new in VB .NET

21Introduction to Visual Studio .NET

About IF Statements

• AndAlso and OrElse do short-circuiting

If intX = 1 AndAlso intY = 2 Then

In above example, second expression is not evaluated if intX is not 1

Page 22: What’s new in VB .NET

22Introduction to Visual Studio .NET

About Object Declarations

• OLDDim objCustomer As Store.CustomerSet objCustomer = New Store.Customer

• NEWImports StoreDim objCustomer = New Customer

ORDim objCustomer as Customer = New Customer

Page 23: What’s new in VB .NET

23Introduction to Visual Studio .NET

About Scope

• New Block-level ScopeDim intX As Integer

For intX = 1 To 5

Dim intZ As Integer

MessageBox.Show(“Scope is important.”)

Next intX

MessageBox.Show(“intZ is out of scope!”)

Page 24: What’s new in VB .NET

24Introduction to Visual Studio .NET

About Arrays• Lower bound is always zero

– Dim intA(5 To 8) no longer is possible– Option Base is gone as well

• Arrays have VERY useful methods• Declare arrays by upperbound, not size – Same

as VB6– Dim strX(10) As String contains 11 elements

• Setting an array to another array is now done by reference– In VB6, this was done by value– Use Copy method of arrays to make an actual copy

Page 25: What’s new in VB .NET

25Introduction to Visual Studio .NET

About Loops

• While…Wend changed to While…End While

Page 26: What’s new in VB .NET

26Introduction to Visual Studio .NET

About Data Types• All variables are objects. Variants are gone.• Type a period after any variable in the IDE to

see methods/properties• Strings are never fixed length. They are

destroyed and recreated by the CLR when value changes– Only one type of string variable for ALL languages

• No Currency data type. Now decimal.• UDTs are gone

– Use structures instead• Structure statement replaces Type• Structures support methods!

Page 27: What’s new in VB .NET

27Introduction to Visual Studio .NET

Useful Options

• Option Strict On– Forces declarations– Forces data types to be same on both sides

of =– Use it always. Get in the habit. Force your

students to use it in assignments.

Page 28: What’s new in VB .NET

28Introduction to Visual Studio .NET

About Operators

• New concatenation operators+, -, *, /, &

intI += 100

intl -= 100

Page 29: What’s new in VB .NET

29Introduction to Visual Studio .NET

About Controls

• Default properties of controls are GONE

• New way to set tab order

• Shape controls are gone– Use System.Drawing namespace

Page 30: What’s new in VB .NET

30Introduction to Visual Studio .NET

About Menus and Help

• Menu editor– Create a menu and a context menu

• Help– Dynamic help is addictive

Page 31: What’s new in VB .NET

31Introduction to Visual Studio .NET

Misc

• New control alignment tools • New properties

– Anchoring and AutoSize– Opacity of forms

• Printing– Several new, powerful printing controls– Print controls/objects get more complicated, but more

powerful– Crystal Reports is included with

Professional/Academic versions• New way to set tab order

Page 32: What’s new in VB .NET

32Introduction to Visual Studio .NET

What’s new in OO?

• Too much to mention• Inheritance• Polymorphism• New syntax for creating properties• Read-only, Write-only properties• Aggregation is weird, though (just in VB)• Constructor = Sub New() : Destructor = Sub

Finalize()– Don’t assume you know when destructor is called

Page 33: What’s new in VB .NET

33Introduction to Visual Studio .NET

What’s new in Databases?

• Too much to mention

• ADO.NET

• SqlClient namespace vs. OleDB namespace

• DataSet and DataTable

• DataReader

• Plea/Editorial: Please don’t use Data controls

Page 34: What’s new in VB .NET

34Introduction to Visual Studio .NET

What will make you scratch your head?• Line numbers are messed up

• Can’t print a form in design mode for a Windows form, but you CAN for a Web form

• Value of True (non-zero, not 1)

Page 35: What’s new in VB .NET

Visual Basic .NETComprehensive Concepts

and Techniques

The End