ch01-introduction to vb

Upload: anekumek

Post on 07-Aug-2018

249 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/21/2019 Ch01-Introduction to VB

    1/22

      1

    rwin/McGraw-Hill rwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Comp

    PowerPoint® PresentationPowerPoint® Presentationto accompany

     prepared byJames T. Perry

    University of San Diego

  • 8/21/2019 Ch01-Introduction to VB

    2/22

      2Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    Ch. 1: Introduction to VBCh. 1: Introduction to VB

    Writing windows applications with V

    Prog. lang!ages" proced!ral# ob$ect

    oriented# % event drivenWriting V pro$ects

    The V environment

    Writing yo!r first V pro$ect&inding % fi'ing errors

    Vis!al asic help

  • 8/21/2019 Ch01-Introduction to VB

    3/22

      (Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    Writing Windows Apps. withWriting Windows Apps. with

    VBVBThe Windows )U*

    Te't bo'es

    &rame

    +abels

    ,ption b!ttons

    -hec bo'es

    -ommand b!ttons

    *mage

    Pict!re bo'

  • 8/21/2019 Ch01-Introduction to VB

    4/22

      /Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    Graphic User InterfaceGraphic User Interface

    )raphic User *nterface 0)U*1 comprises

       &orms

       -ontrols

       3vent4driven programming

  • 8/21/2019 Ch01-Introduction to VB

    5/22

      5Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    Prog. Languages: procedura!Prog. Languages: procedura!

    o"#ect oriented! $ e%ent dri%eno"#ect oriented! $ e%ent dri%enThe ,b$ect 6odel   ,b$ects 0no!ns1   controls

      Properties 0ad$ectives1 form7.-aption

       6ethods 0verbs1 deb!g.print

    Versions of Vis!al asic

       Woring 6odel   +earning 3dition

       Professional 3dition

       3nterprise 3dition

  • 8/21/2019 Ch01-Introduction to VB

    6/22

      8Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    Panning Visua Basic Pro#ectsPanning Visua Basic Pro#ectsThe three4step process for planning pro$ects   Design the !ser interface

    Setch the screens with forms and controls needed

       3stablish the ob$ects9 properties

    Write down the properties for each ob$ect

       Plan the asic code

    Write o!t pse!docode for actions yo!r program will

     perform

  • 8/21/2019 Ch01-Introduction to VB

    7/22

      :Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    Writing Visua Basic Pro#ectsWriting Visua Basic Pro#ectsThe three4step process for writing pro$ects   Design the !ser interface

    -reate the forms and controls yo! previo!sly setched

       Set the ob$ects9 properties

    )ive each ob$ect a name and set their properties

       Write the asic code

    Write o!t Vis!al asic code to carry o!t yo!r

    application9s actions

  • 8/21/2019 Ch01-Introduction to VB

    8/22

      ;Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    Visua Basic Pro#ectsVisua Basic Pro#ects

    Vis!al asic pro$ects create several files   Pro$ect file" .VP

    S 0optional1

       -!stom controls" .,-? 0optional1

       &orm information" .VW

  • 8/21/2019 Ch01-Introduction to VB

    9/22

      @Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    &he Visua Basic 'n%iron(ent&he Visua Basic 'n%iron(ent&orm# Pro$ect 3'plorer# Properties# and

    &orm +ayo!t Windows

    Toolbo'

    6ain Vis!al asic window

    Toolbar# &orm location % siAe information

  • 8/21/2019 Ch01-Introduction to VB

    10/22

      7BCopyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    &he &oo"o)&he &oo"o)

    Tool bo' contents vary based on which

    version of Vis!al asic yo! are r!nning.

    Toolbo' contains a common set of tools

    across all V versions

  • 8/21/2019 Ch01-Introduction to VB

    11/22

      77Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    &he Visua Basic &oo"ar &he Visua Basic &oo"ar 

    The b!ttons on the toolbar are shortc!ts

    Toolbar b!ttons are a C!ic way to activate

    freC!ently !sed commands

    3ach b!tton stands for a command that yo!

    can also select a the Vis!al asic men!

  • 8/21/2019 Ch01-Introduction to VB

    12/22

      72Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    Writing *our +irst VB Pro#ectWriting *our +irst VB Pro#ectSet !p yo!r Vis!al asic worspace

    Define !ser interface

    Set propertiesWrite code

    Vis!al asic code statements

    =!n# save# open# modify# % print the

  • 8/21/2019 Ch01-Introduction to VB

    13/22

      7(Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    ,et Up *our VB Wor-space,et Up *our VB Wor-space

    Set !p ,ptions to reflect these settings"

  • 8/21/2019 Ch01-Introduction to VB

    14/22

      7/Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    efine the User Interfaceefine the User Interface

    =esiAe the form

       Drag the lower4right handle to enlarge the form

       Drag any handle in the middle of a side to

    enlarge the form in that direction only

    Place controls on the form

       -lic the label tool

       -lic and drag the mo!se 0a crosshair1 to place

    the control on the form

  • 8/21/2019 Ch01-Introduction to VB

    15/22

      75Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    ,et Properties,et Properties

    Set the ame and -aption properties   >lways set the ame property before writing

    code   e't# set the -aption property

    The ame property identifies the ob$ect

    internally44so yo! can refer to it in code

    The -aption property e'ternally idenfities

    an ob$ect

  • 8/21/2019 Ch01-Introduction to VB

    16/22

      78Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    Write CodeWrite Code

    Eo! write code enclosed in event procedures# which respond to typical V

    events.Private Sub cmdPush_Click()

     . . . (your code goes here)

    End Sub

    V a!tomatically s!pplies the event proced!re S!bF3nd S!b statements

  • 8/21/2019 Ch01-Introduction to VB

    17/22

      7:Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    Visua Basic Code ,tate(entsVisua Basic Code ,tate(ents

    =emar statement is any code line

     beginning with an apostrophe

    >ssignment statement

    3nd statement

  • 8/21/2019 Ch01-Introduction to VB

    18/22

      7;Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    Code the '%ent ProceduresCode the '%ent Procedures

    for /eo Wordfor /eo WordWrite the P!sh event code for the P!sh 6e

     b!tton 0cmdP!sh1

    Write the P!sh event code for the 3'it

     b!tton 0cmd3'it1

  • 8/21/2019 Ch01-Introduction to VB

    19/22

      7@Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    0un,a%e2pen3odif4 the0un,a%e2pen3odif4 the

    Pro#ectPro#ectTest the pro$ect"   -lic =!n# Start

    0or clic the Start b!tton on the toolbar1

       -lic the P!sh 6e b!tton   -lic the 3'it b!tton

    Save the pro$ect and the form

    6ae modifications to the formPrint the pro$ect doc!mentation"

       &orm *mage# -ode# and &orm as Te't

  • 8/21/2019 Ch01-Introduction to VB

    20/22

      2BCopyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    +inding $ fi)ing errors+inding $ fi)ing errors-ompile 0synta'1 errors

    =!n4Time 0semantic1 errors

    +ogic errors

    Pro$ect Deb!gging

  • 8/21/2019 Ch01-Introduction to VB

    21/22

      27Copyright© 2000 by the McGraw-Hill CompIrwin/McGraw-Hill 

    5a(ing Con%entions5a(ing Con%entions,b$ects have special prefi'es that help

    identify the ob$ect9s general type

    Programmers follow the conventions

     beca!se it simplifies coding and deb!gging

     ever !se defa!lt names for ob$ects

  • 8/21/2019 Ch01-Introduction to VB

    22/22

    22C i ht© 2000 b th M G Hill CI i /M G Hill

    Visua Basic /epVisua Basic /ep