1 Visual Basic “Whidbey”: Advanced Language and IDE Features Steven Lees, Amanda Silver, Program Managers.

Slides:



Advertisements
Similar presentations
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Advertisements

Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
Chapter 6 Multiform Projects Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
VBA Modules, Functions, Variables, and Constants
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Advanced Object-Oriented Programming Features
C# Programming: From Problem Analysis to Program Design1 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program.
Chapter 12: Advanced Topics: Exception Handling Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
ASP.NET Programming with C# and SQL Server First Edition
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Apply Sub Procedures/Methods and User Defined Functions
Neal Stublen Practice Solution  Create a new solution  Add a WinForms project  Add a Class Library project  Reference the library.
Overview of Microsoft.Net and Vb.Net ITSE 2349 Spring 2002 Material from Microsoft.Net an Overview for ACC faculty by Stuart Laughton and Introduction.
McGraw-Hill© 2007 The McGraw-Hill Companies, Inc. All rights reserved. 1-1.
A First Program Using C#
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
DEV334 Creating Application Starting Points & Sharing Best Practices with Enterprise Templates Marc Gusmano Director of Emerging Technologies The Information.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Eric Vogel Software Developer A.J. Boggs & Company.
Microsoft Visual Basic 2005: Reloaded Second Edition
Lesley Bross, August 29, 2010 ArcGIS 10 add-in glossary.
Developing Workflows with SharePoint Designer David Coe Application Development Consultant Microsoft Corporation.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
1 Web-Enabled Decision Support Systems Objects and Procedures Don McLaughlin IE 423 Design of Decision Support Systems (304)
Chapter 6 Understanding the Structure of an Application: Procedures, Modules, and Classes.
Virtual techdays INDIA │ Nov 2010 Developing Office Biz Application using WPF on Windows 7 Sarang Datye │ Sr. Consultant, Microsoft Sridhar Poduri.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
.NET Framework Danish Sami UG Lead.NetFoundry
DEV325 Deploying Visual Studio.NET Applications Billy Hollis Author / Consultant.
The Java Programming Language
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
10 – 12 APRIL 2005 Riyadh, Saudi Arabia. Building multi-lingual ASP.Net application that handle western languages and Arabic with a single code base.
Introduction to Exception Handling and Defensive Programming.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Multiform Projects.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
C# 2.0 and Future Directions Anders Hejlsberg Technical Fellow Microsoft Corporation.
DEV330 Visual Studio.NET IDE Tips and Tricks Billy Hollis Author / consultant.
Web Services Error Handling and Debugging. Agenda Simple SOAP faults Advanced SOAP faults SOAP headers and faults Error handling From a Service Perspective.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Presented by Vishy Grandhi.  Architecture (Week 1) ◦ Development Environments ◦ Model driven architecture ◦ Licensing and configuration  AOT (Week 2)
M1G Introduction to Programming 2 5. Completing the program.
6-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Tips & Tricks: Writing Performant Managed Code Rico Mariani FUNL04 Performance Architect Microsoft Corporation.
1 Visual Basic “Whidbey”: RAD for the Visual Basic Developer Jay Schmelzer and Shamez Rajan Program Manager Microsoft Corporation Jay Schmelzer and Shamez.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
Visual Basic 2005: Advanced Language and IDE Features Amanda Silver Program Manager Visual Basic Session Code: DEV343.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
DEV394.NET Framework: Migrating To Managed Code Adam Nathan QA Lead Richard Lander Program Manager Microsoft Corporation.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
Visual Basic Tip Tricks and Other Advanced Topics Bill McCarthy Nick Randolph DEV313.
Session 02 Module 3: Statements and Operators Module 4: Programming constructs Module 5: Arrays.
Creating New Forms Projects can appear more professional when using different windows for different types of information. Select Add Windows Form from.
Integrating and Extending Workflow 8 AA301 Carl Sykes Ed Heaney.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Mike Harsh PRSL001 Program Manager Microsoft Corporation
Microsoft Visual Basic 2005: New Language Features
VBA - Excel VBA is Visual Basic for Applications
Visual Studio Tools for Office 2005
Microsoft Access Illustrated
Using Procedures and Exception Handling
Customizing your device experience with assigned access
VISUAL BASIC.
What's New in Visual Studio 2005
Jochen Seemann Program Manager Enterprise Tools Microsoft Corporation
Getting Ready for Visual Studio 2005
Windows Forms in Visual Studio 2005: An in-depth look at key features
Mark Quirk Head of Technology Developer & Platform Group
Presentation transcript:

1 Visual Basic “Whidbey”: Advanced Language and IDE Features Steven Lees, Amanda Silver, Program Managers Microsoft Corporation Steven Lees, Amanda Silver, Program Managers Microsoft Corporation Session Code: TLS300

2 Agenda Advanced IDE Features Lots of new language features Full platform support Advanced IDE Features Lots of new language features Full platform support

3 Advanced IDE Features Application Designer Settings Extensible code snippets Rename Symbol New Async calling convention Application Designer Settings Extensible code snippets Rename Symbol New Async calling convention

4 Configuration and Settings Basic support in VS 2002 and 2003 App.config contains settings in XML Framework class for reading settings Can extend with additional capabilities Straightforward, but not really easy Basic support in VS 2002 and 2003 App.config contains settings in XML Framework class for reading settings Can extend with additional capabilities Straightforward, but not really easy

5 Configuration and Settings Huge improvements in Whidbey Framework classes support read/write Strongly-typed access to settings IntelliSense for settings Choose app-scoped or user-scoped settings Works in partial trust Validation model Extensible provider model Shared infrastructure across client and web Huge improvements in Whidbey Framework classes support read/write Strongly-typed access to settings IntelliSense for settings Choose app-scoped or user-scoped settings Works in partial trust Validation model Extensible provider model Shared infrastructure across client and web

6 Settings Architecture SettingsBase ApplicationSettingsBase WindowsApp1Settings Provider Interface Local Settings RemoteSqlCustomAccessCustom My.Settings

7 Settings Architecture Customizable At the provider level By writing custom settings classes Customizable At the provider level By writing custom settings classes

8

9 Settings Designer allows Creating / modifying / deleting entries Type of entry (for strong typing) Choosing user-scoped or app-scoped Default value Different “profiles” Special support for Connection Strings Web service proxies VS will automatically create settings Designer allows Creating / modifying / deleting entries Type of entry (for strong typing) Choosing user-scoped or app-scoped Default value Different “profiles” Special support for Connection Strings Web service proxies VS will automatically create settings

10 Settings Architecture App settings User Settings Myapp.exe.config … fred.config … ethel.config … gladys.config …

11 Code Samples Load Save Handling events for validation Load Save Handling events for validation My.Settings.UseHighQuality = True ‘ Settings automatically loaded on first access Private Sub Settings_SettingChanging(ByVal sender As Object, ByVal e As SettingsArg) Handles MyBase.SettingChanging If e.SettingName = “SignatureFile” Then If e.SettingName = “SignatureFile” Then If Not My.Computer.FileSystem.FileExists(e.Setting.Value) Then If Not My.Computer.FileSystem.FileExists(e.Setting.Value) Then ‘ Cancel event ‘ Cancel event End If End If End Sub My.Settings.UseHighQuality = True My.Settings.Save()

12 Advanced IDE Features Application Designer Settings Extensible code snippets Rename Symbol New Async calling convention Application Designer Settings Extensible code snippets Rename Symbol New Async calling convention

13 Application Designer One stop shopping for app settings Resources App and user settings References Version Info Deployment Easier to find Non-modal window for better usability One stop shopping for app settings Resources App and user settings References Version Info Deployment Easier to find Non-modal window for better usability

14 Application Designer New Application Events Startup Shutdown Unhandled exception Network connected Network disconnected New Application Events Startup Shutdown Unhandled exception Network connected Network disconnected

15 Advanced IDE Features Application Designer Settings Extensible code snippets Rename Symbol New Async calling convention Application Designer Settings Extensible code snippets Rename Symbol New Async calling convention

16 Extensible Code Snippets Code snippets have standard schema You can add items to the right-click menu Snippet editor For creating, editing snippets Multiple snippet stores Local or network share Easy way to package code for reuse Sharing is encouraged! Code snippets have standard schema You can add items to the right-click menu Snippet editor For creating, editing snippets Multiple snippet stores Local or network share Easy way to package code for reuse Sharing is encouraged!

17 Rename Symbol Quick way to change identifiers Rename all cases of “TextBox1” Type declaration Variable declarations Events More precise than text replacement Doesn’t affect comments Working on other “refactoring” features Create method Rename all cases of “TextBox1” Type declaration Variable declarations Events More precise than text replacement Doesn’t affect comments Working on other “refactoring” features Create method

18 Advanced IDE Features Application Designer Settings Extensible code snippets Rename Symbol New Async calling convention Application Designer Settings Extensible code snippets Rename Symbol New Async calling convention

19 Asynchronous calling Easier way to call slow background tasks Model asynchronous calls as events PictureBox1.LoadAsync(url) PictureBox1_LoadCompleted(…, …) Completion routine is on main thread Web service proxies Supports progress, cancellation Background worker component Easier way to call slow background tasks Model asynchronous calls as events PictureBox1.LoadAsync(url) PictureBox1_LoadCompleted(…, …) Completion routine is on main thread Web service proxies Supports progress, cancellation Background worker component

20 Background Worker Structure BackgroundArgs Dim arg1 As Integer Dim arg1 As Integer Dim arg2 As String Dim arg2 As String End Structure Private Sub Button1_Click(…) Handles Button1.Click Dim args As BackgroundArgs Dim args As BackgroundArgs BackgroundWorker1.RunWorkerAsync(args) BackgroundWorker1.RunWorkerAsync(args) End Sub Private Sub BackgroundWorker1_DoWork(…) Handles BackgroundWorker1.DoWork ‘ This is run on a background thread ‘ This is run on a background thread Dim args As BackgroundArgs Dim args As BackgroundArgs args = CType(e.Argument, BackgroundArgs) args = CType(e.Argument, BackgroundArgs) ‘ Now do something on the background thread ‘ Now do something on the background thread e.Result = e.Result = End Sub Private Sub BackgroundWorker1_RunWorkerCompleted(…) Handles Background… result = e.Result result = e.Result End Sub

21 Advanced IDE Features

22 New Language Features Explicit array bounds Using statement Continue statement Global keyword Accessor accessibility Partial types Unsigned types Operator Overloading Generics Warnings Explicit array bounds Using statement Continue statement Global keyword Accessor accessibility Partial types Unsigned types Operator Overloading Generics Warnings

23 Explicit Array Bounds Arrays are still zero based You can now specify the lower and upper bounds in the declaration Arrays are still zero based You can now specify the lower and upper bounds in the declaration ‘In VS 2002 and 2003, you did it this way Dim x(10) As Integer ‘Now you can also declare it like this Dim y(0 To 10) As Integer

24 Using Statement Acquire, Execute, Release Fast way correctly release resources Easier to read than Try, Catch, Finally Couple with Dispose Pattern stub gen Fast way correctly release resources Easier to read than Try, Catch, Finally Couple with Dispose Pattern stub gen ‘Using block disposes of resource Using fStr As New FileStream(path, FileMode.Append) For i As Integer = 0 To fStr.Length For i As Integer = 0 To fStr.Length fStr.ReadByte() fStr.ReadByte() Next Next ‘End of block will close stream ‘End of block will close stream End Using

25 Continue Statement Skips to next iteration of loop Loop logic is concise, easier to read For j As Integer = 0 to 5000 While matrix(j) IsNot thisValue While matrix(j) IsNot thisValue If matrix(j) Is thatValue If matrix(j) Is thatValue ‘ Continue to next j ‘ Continue to next j Continue For Continue For End If Graph(j) Graph(j) End While End While Next j

26 Global Keyword Access to root (empty) namespace Complete name disambiguation Better choice for code generation Complete name disambiguation Better choice for code generation Namespace HeadTrax Class Form1 Class Form1 Inherits Windows.Forms.Forms Sub LastName(nm As String) Sub LastName(nm As String) Global.Microsoft.VisualBasic.Left(nm) Global.Microsoft.VisualBasic.Left(nm) End Sub End Sub End Class End Class End Namespace

27 Accessor Accessibility Granular accessibility on Get and Set Forces calls to always use get, set Easy way to enforce validation Forces calls to always use get, set Easy way to enforce validation Property Salary() As Integer Get Get Return mSalary End Get End Get Private Set( value As Integer) Private Set( value As Integer) If value < 0 Then Throw New Exception(“Mistake”) Throw New Exception(“Mistake”) End If End Set End Set End Property

28 Partial Types Single Structure, Class in Multiple Files Used to separate designer gen into another file Factor implementation Used to separate designer gen into another file Factor implementation Public Class Form1 Inherits Windows.Forms.Form Inherits Windows.Forms.Form ‘ Your Code End Class Partial Class Form1 ‘ Designer code Sub InitializeComponent() ‘ Your controls ‘ Your controls End Sub End Class

29 Unsigned Types Full support in the language Full platform parity Easier Win32 Api calls and translation Memory and performance win Full platform parity Easier Win32 Api calls and translation Memory and performance win Dim sb As SByte = -4 ‘Error:negative Dim us As UShort Dim ui As UInteger Dim ul As ULong ‘Full support in VisualBasic modules If IsNumeric(uInt) Then ‘ Will now return true End If

30 New Language Features

31 Operator Overloading Create your own base types Class Addr Private mString As String Private mString As String Property Value() As String Property Value() As String Get Get Return mString Return mString End Get End Get Set (value As String) Set (value As String) If Valid(value) Then If Valid(value) Then mString = value mString = value End If End If End Set End Set Shared Operator &(ad1 As Addr, ad2 As Addr) _ Shared Operator &(ad1 As Addr, ad2 As Addr) _ As Addr As Addr Return New Addr(ad1.Value & ad2.Value) Return New Addr(ad1.Value & ad2.Value) End Operator End Operator

32 Operator Overloading

33 List intList = new List() intList.Add(1) ‘ Argument is boxed intList.Add(2) ‘ Argument is boxed intList.Add("Three") ‘ Should be an error int i = CInt(intList(0)) ‘ Cast required Generics Public Class List Public Class List Private elements() As ItemType Private elements() As ItemType Private count As Integer Private count As Integer Public Sub Add(element As ItemType) Public Sub Add(element As ItemType) If (count = elements.Length) Then _ If (count = elements.Length) Then _ Resize(count * 2) Resize(count * 2) count += 1 count += 1 elements(count) = element elements(count) = element End Sub End Sub Public Property default(index As Integer) As ItemType Public Property default(index As Integer) As ItemType Get : Return elements(index) : End Get Get : Return elements(index) : End Get Set : elements(index) = value : End Set Set : elements(index) = value : End Set End Property End Property Public Property Count As Integer Public Property Count As Integer Get : Return count : End Get Get : Return count : End Get End Property End Property End Class Public Class List Private elements() As Object Private elements() As Object Private mCount As Integer Private mCount As Integer Public Sub Add(element As Object) Public Sub Add(element As Object) If (mCount = elements.Length) Then _ If (mCount = elements.Length) Then _ Resize(mCount * 2) Resize(mCount * 2) mCount += 1 mCount += 1 elements(mCount) = element elements(mCount) = element End Sub End Sub Default Public Property i(index As Integer) As Object Default Public Property i(index As Integer) As Object Get Get Return elements(index) Return elements(index) End Get End Get Set Set elements(index) = value elements(index) = value End Set End Set End Property End Property Public Property Count() As Integer Public Property Count() As Integer Get : Return mCount : End Get Get : Return mCount : End Get End Property End Property End Class Dim intList As New List intList.Add(1)intList.Add(2)intList.Add("Three") Dim i As Integer = intList(0) Dim intList As New List(Of Integer) intList.Add(1) ‘ No boxing intList.Add(2) ‘ No boxing intList.Add("Three") ‘ Compile-time error int i = intList(0) ‘ No cast required

34 Generics (Specifics) Compile Time Checking Eliminates runtime errors Performance No casting or boxing overhead Code reuse Easy to create strongly typed collections Generic Collection classes in Framework Dictionary, HashTable, List, Stack, etc. Compile Time Checking Eliminates runtime errors Performance No casting or boxing overhead Code reuse Easy to create strongly typed collections Generic Collection classes in Framework Dictionary, HashTable, List, Stack, etc.

35 Generics

36 Visual Basic Warnings Early warning of bad runtime behavior Overlapping catch blocks or cases Recursive property access Unused Imports statement Unused local variable Function, operator without return Reference on possible null reference Option Strict broken down “Late binding” VB Style Conversions Etc. Overlapping catch blocks or cases Recursive property access Unused Imports statement Unused local variable Function, operator without return Reference on possible null reference Option Strict broken down “Late binding” VB Style Conversions Etc.

37 Warnings

38 Additional Resources Related sessions TLS343 – Visual Studio “Whidbey”: Advanced Debugging Techniques (Tuesday 5:15 Room 408 AB) TLS344 – Visual Studio “Whidbey”: Deploying Applications Using ClickOnce (Wednesday 10:00 Room 511 ABC) ARC413 – CLR Under the Covers: “Whidbey” CLR Internals (Wednesday 5:00 Room 152/153) Related sessions TLS343 – Visual Studio “Whidbey”: Advanced Debugging Techniques (Tuesday 5:15 Room 408 AB) TLS344 – Visual Studio “Whidbey”: Deploying Applications Using ClickOnce (Wednesday 10:00 Room 511 ABC) ARC413 – CLR Under the Covers: “Whidbey” CLR Internals (Wednesday 5:00 Room 152/153)

39 Additional Resources Panels Ask The Experts (Tonight) Languages Panel (Thursday) Send us feedback! Newsgroup: microsoft.public.dotnet.vb Other resources Paul Vick’s blog: Panels Ask The Experts (Tonight) Languages Panel (Thursday) Send us feedback! Newsgroup: microsoft.public.dotnet.vb Other resources Paul Vick’s blog:

40 Summary Ease of use is built on solid infrastructure Many points of extensibility Very powerful new language features And some cool fit and finish ones too Full access to the platform Please fill out the eval! (Thank you!) Ease of use is built on solid infrastructure Many points of extensibility Very powerful new language features And some cool fit and finish ones too Full access to the platform Please fill out the eval! (Thank you!)

41 © Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.