Introduction to VB'Net - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Introduction to VB'Net

Description:

The synergy Microsoft obtained from VB6 and VBA will mean that VB.NET will ... ProductName='Widgets' End Property. Public Property Get ProductName(NewValue as String) ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 14
Provided by: bril
Category:

less

Transcript and Presenter's Notes

Title: Introduction to VB'Net


1
Introduction to VB.Net
  • AWPP Annual Conference
  • 2003

2
Evolution
  • At previous conference looked at the evolution of
    VB from its roots as BASIC in the 1960s
  • VB7 or Visual Basic.NET is more of a revolution
    than an evolution.
  • Is now part of the cross language Visual
    Studio.Net to create multilanguage solutions.
    Cross Language Runtime CLR and Common Type System
    CTS to enable communication between modules
    written in different languages are part of the
    Common Language Specification CLS.
  • Many of the techniques of VB6/VBA are legacy and
    now only present for compatibility, eg functions
    like mid although available are better handled
    using replacements from the new paradigm
  • The synergy Microsoft obtained from VB6 and VBA
    will mean that VB.NET will likely be the
    framework for future versions of Office

3
VB6/VBA vs VB.Net
  • Although VB6/VBA embraced some of the concepts of
    OOP (Objected Oriented Programming), it could
    still be viewed as a procedural language
  • VB.Net maintains some of the procedural
    techniques from the past but more for
    compatibility
  • VB.Net is OOP
  • VB.Net and VB6 can coexist on same machine
  • VB.Net full install weighs in at around 2Gb
  • VB.Net development cannot be done of Win98, but
    you can write programs for Win98
  • When you open VB.Net you actually run Visual
    Studio.Net
  • In the past you had Class files .cls, Modules
    .bas, Form filesa .frm, now all in the one or
    multiple .vb files. Or C .vs or C .vc files

4
Whats in the box with the dot Net
  • A pack of charts showing the .Net Framework and
    object model
  • A sampler book, with sample chapters from three
    Microsoft Press books
  • License information
  • Quick install guide
  • 3xCDs with an installed load of about 2Gb
  • Includes documentation
  • Sample applications
  • Technology articles

5
IDEIntegrated Development Environment
  • Same across each language
  • Integrates Visual Sourcesafe
  • Same environment for Web Project as Windows
    Project
  • Top level of application is a Solution
  • Projects are same language components of that
    solution
  • Collapsible Regions of code
  • Managed Assemblies, also can include unmanaged
    COM objects

6
Namespaces
  • Namespaces are a means of organising objects and
    source code.
  • In the past Classes, Modules and Forms were kept
    in separate files, now they can, if so wanted, be
    kept in one file, grouped into Namespaces
  • EG Namespace IniHandler
  • Public Class IniFile
  • Properties and methods for Inifile
  • End Class
  • Public Class IniSection
  • Properties and methods for IniSection
  • End Class
  • Public Class IniItems
  • Properties and methods for IniItems
  • End Class
  • End Namespace

7
Namespaces
  • Namespaces can be nested, and items can be
    referenced by their typeful names
  • Eg
  • Namespace Factory
  • Public Class Employee
  • properties and methods
  • End Class
  • Namespace Conveyors
  • Public Class ConveyorLine
  • properties and methods
  • End Class
  • End Namespace
  • End Namespace
  • Typeful name example Factory.Conveyors.ConveyorL
    ine
  • Alias using the Imports make referencing classes
    easier... Eg
  • Imports RegSettings Microsoft.Win32.Registry
  • RegSettings.CurrentUser.CreateSubkey(AWPP)

8
Set and Get properties
  • In VB6/VBA
  • Public Property Get ProductName() as String
  • ProductNameWidgets
  • End Property
  • Public Property Get ProductName(NewValue as
    String)
  • mstrProductName NewValue
  • End Property
  • In .Net
  • Public Property ProductName() as String
  • Get
  • ProductName Widgets
  • End Get
  • Set
  • mstrProductName ProductName
  • End Set
  • End Property

9
Polymorphism, Encapsulation and Inheritance
  • Polymorphism different objects presenting the
    same interface. Eg Customer.Add, Order.Add
  • Existing feature of VB6
  • Encapsulation ability to hide underlying code
  • Existing in VB6/VBA
  • Inheritance New to VB.Net
  • Superclass, Parent Class or Base Class
  • Subclass, Child Class
  • Eg Class HotelRoom as Superclass
  • Class DeluxeRoom as Subclass

10
Data Types
  • Consolidation of data types across platforms, so
    VB.Net shares same data types as C C,
    interoperability
  • Variant and Currency types banished, as are fixed
    length strings
  • Longs are now 64 bit, Integer is 32 bits and
    Short is 16 bits
  • Strings now unbounded to 2Gb length

11
Option Base, Explicit, Strict
  • No Option Base 1, all arrays zero-based
  • Option Explicit is default
  • Option Strict is default
  • Eg
  • Dim intItem as integer
  • Dim strName as string
  • strName ItemNumber intItem
  • Will not work

12
VB6/VBA On Error Goto Hell
  • Public Sub CopyFileOnDiskette()
  • On Error Goto Hell
  • Various Code,
  • ExitHere
  • Exit Sub
  • Hell
  • Select Case Err.Number
  • Case 57
  • MsgBox No Diskette, Insert a diskette
  • Case 53
  • MsgBox File not found
  • End Select
  • Resume ExitHere
  • End Sub

13
VB.Net Try - Catch
  • Public Sub AddNames()
  • Try
  • Dim arr Names(10) as String
  • Dim intCount as Integer
  • For intCount 1 to 20
  • arrNames Brian
  • Next
  • Catch
  • ? Err.description()
  • Finally
  • ? It finally finished
  • End Try
  • End Sub
  • There can be multiple Catchs each with an
    exception case.
Write a Comment
User Comments (0)
About PowerShow.com