vbDay3 by sourabhdua88


More Info
									  Differences between VB 6.0 & VB.NET
1) It is an object based     1) It is an object oriented
programming                  programming
2)Variables or member        2)Here its mandatory
declarations are not
mandatory                    3) Uses Unstructured /
3)Uses Unstructured          Structured methods for
method for handling          handling exception
exceptions                   4) supports ADO and
4) Uses DAO, RDO, ADO        ADO.NET models
object models for
database connectivity        5) uses crystal reports
5)Uses Data projects as
its default reporting tool
6)Uses COM for language        6) Uses .net assembly for
interoperability               language interoperability
7)Does not support multi       7)Does support
threading                      multithreading
8)Uses DCOM to support         8)Uses .net remoting to
distributed technology         support distributed tech.
9) Supports web tech.,client   9)It does not support web
side appns or server side      technology.
appns can be designed          Note VB.net cant be used to
using VB                       design Client Side / Server
                               side appns but it can used
                               as an implementing Lang
                               for asp.net
    Differences between C#.net & VB.net
W.R.T               C#.NET                        VB.NET
DATA         1.Unsigned Data        1.No Unsigned Data Types
TYPES        Types                  2.It is not strongly typed
             2.Strongly Typed Lang.
OOPS         More concepts in C#       Less Concepts here.
Concept      u have interfaces,        No indexes in Vb.net and it
             abstraction, indexes      has limitations wrt interface
Memory       Garbage Collector.        Garbage collector,
Manag.       Automatic releasing of    destructor,dispose.Automatic
             resources is available.   releasing of resources is not
             It Boosts the             available.You have to explicitly
             performance.              use dispose method
Operator    Is available in C#         Is not available in VB.Net
Pointers     Is available in C#        Is not available in VB.Net

Auto XML     Is available in C#        Is not available in VB.Net
Structure of a VB.Net Console Application
     1 method:-

        Class <Class Name>
           Public Shared Sub Main()
                 „Statements
            End sub
        End class
     2nd method
        Module <Module Name>
            Sub Main()
                 „statements
           End sub
         End module
         Note : Difference is we are using Public
          Shared in Class and we r not using Public
          Shared in Module (2nd method)
   Vb.Net is not case-sensitive but it is a line sensitive
   The base class for any .net is SYSTEM.
      For eg: system.console
          System is a Base Namespace

          Console is a namespace or a class used to
           support console applications
      If it is web then it is
          System.web
   System.Console
       Writing
          Write()
             Just writes the information

          WriteLine()
             Used for writing the information along
              with in a new line
          These 2 methods are for writing the
           information on the screen
       Reading
          Read()
             Accepting a single character something
              like getchar() in c
          ReadLine()
             Accepts the I/P till the user press the
Declaration of variables in VB.net
Syntax Modifier variablename [as datatype][=value]
Modifiers usage it is used for specifying the access
control for a member of a class.

       In VB 6.0                 In VB.Net
   Dim a,b,c as integer      Dim a,b,c as integer
       a,b are varients
   Dim I as integer =10      Dim I as integer=10
       this is error             This is valid
   Dim V                     Dim O
   Default datatype is       Default is object
   Data Types :
    Byte  Occupies 1 byte
    Short  2 bytes
    Integer  4 bytes
    Long  8 bytes
    Single  4 bytes
    Double  8 bytes
    Decimal 10 bytes
    Boolean  2 bytes true / false
    Date  8 bytes
    format is MM/DD/YYYY
    Range is 01/01/0001 to 12/31/9999
    Char – 2 bytes
    String – 2 billin characters
    Object – 4 bytes
   Array: it can be defined as collection of elements similar type of
    data grouped under one name and each element is identified with
    unique index.
    Dim a(2) as byte
    Lower bound is 0 and upper bound is 2 ( here it has elements are
    Note : In Vb6.0 lower bound can be any numbers
   2. In vb.net the lower bound is fixed to zero since it supports all
    languages no language can go as lower bound as zero so here
    thee zero is fixed as lower bound.
   1. Dim a() as byte ={1,2,3,4}
    2. a.length = 4  length –1 is the upper bound
                     so,4-1 =3 is the upper bound
   It is a collection of member variables(data) and
    methods(member functions)
   syntax 
    Modifier class <class Name>
    End class
    Note:Where the members of the class can be
    instance members.
   Instance members  these members
    will be binded to the objects and hence
    these members can be referred with
    reference to the object name only.
       Note  the memory for these members will
        be allocated in each and every object
        defined for a class.
   Shared Members  Those members will
    be shared among all the objects defined
    for a class.
       Note  these members will be initialized
        when ever the class is loaded for the first
       These members can be accessed before
        creation of an object for the class.
   Data members come under 5 types of access modifiers
      Private  It is accessible within the class only
      Public  It can be accessed from any where
      Protected  It means they are accessible only from with
        in their own class and sub classes as well.
      Friend  They are accessible from with in the program
        that contains their declarations as well as any where else
        in the same assembly.
      Protected friend  Gives variable both protected and
        friend access which means they are accessible only with
        in there declaration context,Including any nested
   It is an instance of an class. ( Or ) It can be
    considered as an entity with attributes and
   Syntax 
        Modifier objectName as new ClassName()
   Or
        Modifier objectName as className
        objectName = new className()

        See example  Module 9
                    OOP’S Feature
   Data Abstraction or Hiding It is used to show the relevant
    information data and to hide the irrelevant information from
    the user.
           To achieve this modifiers are used.
   Data Encapsulation or Binding It is used to identify the
    relevant info or data and to group that data together.
           To achieve this classes and structures are used.
   Polymorphism  if an entity can change its form as per the
    requirement then it is said to be polymorphism.
        To achieve this overloading concept is used.
        Note  if any language or a product supports the above
         3 features alone then it is said to be object based
         language or product.
   Inheritance  it is used to reuse or redefine the existing
    class definitions
        .net supports single and multi-level inheritance.
        Interface in .net can be used to achieve multiple
   In arrays we have the only one datatype
    with the same name but if we want to
    declare a user defined datatype which
    consists of two or more different datatypes
    for that we go to the concept of structures
   Syntax:-
   Public structure student
       Public sno as integer
       Public sname (20) as string
   End structure
    see example{ structure,structure1}
   it is a set of instructions, which is used to
    perform an action or task.It is a subprogram,
    which will not return any value.
    Syntax 
    modifier sub procedure Name ([argInfo])
    end sub
        where argInfo (Argument Info)
        is [byValue / byreference] argName as dataType
   Normally we use both call by value and also the
    call by reference but in vb.net default is call by
    {See example
   It is a set of instructions to perform calculations
    or expression evaluations.
       Syntax 
        modifier function functionname([argoInfo]) as <return datatype>
           return<return value>
               end Function.
    Note: to terminate a procedure or a function
    abruptly Exit sub or exit function can be used.
   It is used to set or get a value from the private or protected
    members of a class
    Public[readonly/write only] property propertyname () as
       Set
       End set
       Get
                 Return <return value>
       End get
        End property
   Note: value is a keyword, which holds the
    value passed or assigned by the user at the
   If readonly keyword then only get method
    should be defined and if write only
    keyword is used then only set method
    should be defined
   It is used to initialize the members of the class.
   Note: if a class is not defined with any constructor
    implicitly the CLR will provide a constructor, which is
    called as default constructor.
   Constructors are of 2 types 
   Instance constructors  it is used to initialize the
    instance and the shared members of the class.
   Note  these constructors will be invoked every time a
    new object is defined for a class.
   Shared Constructors  it is used to initialize the shared
    members of a class.
   Note  shared constructors will be invoked for the first
    time the class is loaded on to the memory.
   If the shared constructor is defined for a class it is
    mandatory to have a instance constructor with the same
   Syntax  [shared] sub new ([argInfo])
                end sub

   By default it is “INSTANCE CONSTRUCTORS”
   NOTE: If the constructor accepts any args then it is
    said to be parameterized constructor else it will be called
    as no-arg constructor.
   When ever a class has more than 1 constructor then the class
    is overloaded with constructors.
    If a class is defined with constructor then CLR will not create
    a default constructor. It will search for a constructor.
   Whenever the members of the class and the methods are same
    in order to refer the class members they should be prefixed
    with “me” Keyword.(I.e to access the parent class)
   If there is no suitable constructor present in the class then
    object cant be defined for that class.
   Points to remember :  whenever the value for the shared
    members are constant then it is advisable not to initialize the
    shared member variables within the instance constructors as
    these constructors will be invoked everytime a new object is
    defined for the class.
   Copy Constructor :It is used to copy the value of
   the members present in one object to another object.
 Syntax:
      Sub new (object as className)
             Variable = object.variable
      End sub
To define an object based on the copy constructor
Modifier targetobject as new classname(source object)

To top