Chapter 01
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,595
On Slideshare
1,588
From Embeds
7
Number of Embeds
1

Actions

Shares
Downloads
42
Comments
0
Likes
0

Embeds 7

http://tyoastos.pbworks.com 7

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • Brief description on how to navigate within this presentation (ppt) The first time a Key Term from the chapter is used in the ppt it will display in blue Gold colored text boxes display coding examples Slides will be numbered (# of #) when multiple slides on same topic (Slide title) Speaker notes are included where appropriate for slides (*)Denotes either a comment for page reference to textbook or slide reference in ppt
  • Planning- Design the user interface—draw a sketch of the screens the user will see when running the project; include forms and all controls that are to be used including the names to be assigned Plan the properties—for each object write down the properties that you plan to set or change during the design of the form Plan the Basic code—plan the classes and procedures that will execute when the project runs including determining which events require action to be taken and then make a step-by-step plan for the actions Programming- Define the user interface-- create Forms and Controls Set the properties--give each object a name and define attributes such as the contents of a label, size, Write the Basic code—use Basic programming statements to carry out the actions needed by the program
  • Solution file-text file that holds information about the solution and the projects it contains; primary file Solution user options file-stores information about the selected options A.Vb file—holds the definition of a form, its controls, and code procedures Resource file—a text file that defines all resources used by the form including string of text, numbers and any graphics Project file—text file that describes the project and lists the files that are included in the project Project user option file—text file holds project option settings so that the next time a project is opened all selected options are restored
  • IDE tools Form designer-visually create a form Editor-entering and modifying program code Compiler-for translating the Visual Basic statements into the intermediate machine code Debugger-to help locate and correct program errors Object browser-to view the available classes, objects, properties, methods and events Help facility-to provide answers to questions
  • Toolbars—are shortcuts for frequently used operations; each button represents a command Document Window—largest window in the center of the screen; items that display in the Document window include: Form Designer, the Code Editor, the Object Browser, and the pages of Help that are requested Form Designer—where a form is designed that makes up the user interface Solution Explorer Window—holds the filenames for the files included in your project and a list of the classes it references Properties Window—used to set the properties for the objects in a project Toolbox—holds tolls that are used to place controls on a form Help—is expanded for >NET and includes the Microsoft Developer Network library containing reference materials for VB and other languages; as well as books, technical articles, Microsoft Knowledge Bases, and a database of FAQ’s.
  • The Title Bar indicates which mode is currently being used.
  • Step 1—set up the Workspace; run Visual Studio IDE and customize the workspace if desired Step 2—start a New Project Step 3—set up the environment—customize windows and toolbars
  • Design the user interface by making a sketch of the form that includes the controls Resize the form in the document window; drag the handle (key term) in the lower-right corner Place the controls by pointing to the tool in the toolbox and clicking to select; drag the pointer over the form and the pointer becomes a crosshair; point to a spot to place the corner of the control and drag to create the control; a selected control that is selected will have 8 small square handles around it (Button 2) Once the controls have been selected and placed on the form right-click on one of the controls and select Lock Controls from the context menu
  • Click on the control and then click in the properties window to select and change desired properties of the control and/or form
  • You write code in VB in procedures; currently each procedure will be a sub procedure (Key Term) and being with the words Private Sub and end with End Sub
  • Details for the Remark statement, assignment statement, ending a program and the editor window are shown on the following 4 slides
  • When double-clicking on a button the Visual Studio editor opens with the first and last one of your sub procedure already in place and the insertion point indented inside the sub procedure Declaration section – section at the top of the file
  • Run the project to determine if there are any errors (debugging) that need to be fixed. Save All saves the current form, project, and solution files to the path that was selected when you started the project. You cannot change the path after beginning a project. If wanting to move or rename the project it must be closed. Modify project is you want to change the controls or control properties such as font size, size of a label, etc.
  • Using good consistent names for objects can make a project easier to read and understand, as well as easier to debug. When you select a name for an object, Visual Basic requires the name to begin with a letter or an underscore; names can contain letters, digits, and underscores but no spaces, punctuation marks or reserved words such as Exit or It. Camel casing is beginning the name with a lowercase character and capitalize each additional word in the name.
  • MSDN-Microsoft Developer Network library A good way to start using Help is to view the topics that demonstrate how to look up topics in Help.
  • A quick way to view Help on any topic is to use context-sensitive Help (Key term)

Transcript

  • 1. aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf
  • 2. Introduction to Visual Basic.NET 2005 Chapter 1 McGraw-Hill © 2006 The McGraw-Hill Companies, Inc. All rights reserved.
  • 3. Chapter Objectives (1 of 2)
    • Describe the process of visual program design and development
    • Explain the term object-oriented programming
    • Explain the concepts of classes , objects , properties , methods , and events
    • List and describe the three steps for writing a Visual Basic project
    • Describe the various files that make up a Visual Basic project
  • 4. Chapter Objectives (2 of 2)
    • Identify the elements in the Visual Studio environment
    • Define design time , run time , and debug time
    • Write, run, save, print, and modify your first Visual Basic project
    • Identify syntax errors , run-time errors , and logic errors
    • Use Auto Correct to correct syntax errors
    • Look up Visual Basic topic in Help
  • 5. Writing Windows Applications with VB (1 of 2)
    • Windows Graphical User (GUI) Interface
      • Defines how elements look and function
  • 6. Writing Windows Applications with VB (2 of 2)
      • Elements are called controls and are added using a toolbox
    Windows are called forms
  • 7. Programming Languages-Procedural, Event Driven and Object Oriented
    • Procedural —Cobol, Fortran, Basic
      • Program specifies exact sequence of all operations
    • Event Driven (VB 6.0 and previous)
      • Contain some elements of Object oriented programming but not all
    • Object Oriented Programming (OOP) (VB .NET)
      • User controls sequence
        • Click event
        • Double Click event
        • Change event
  • 8. The Object Model (1 of 2)
    • In VB you will work with objects, which have properties, methods, and events. Each object is based on a class.
    • Objects equate to Nouns
      • Forms are windows
      • Controls are components contained inside a form
    • Properties equate to Adjectives
      • Color or size of a Form
    • Methods are like Verbs
      • Typical methods include Close, Show and Clear
  • 9. Object Model (2 of 2)
    • Events occur when the user takes action
      • User clicks a button , User moves a form
    • Classes are templates used to create a new object
      • Classes contain the definition of all available properties, methods, and events
      • Each new object created is based on a class
        • Creating three new buttons makes each button a instance of the Button class
  • 10. Object Model Analogy
    • Class = automobile
    • Properties = make, model, color, year
    • Object = each individual car
      • Object is also an Instance of the automobile class
    • Methods = start, stop, speedup, slowdown
    • Events = car arrives, car crashes
  • 11. Visual Studio .NET
    • Included in Visual Studio .NET 2005
      • Visual Basic (can also be purchased separately)
      • Visual C++
      • C# (C sharp)
      • J# (J sharp)
      • .NET 2.0 Framework
    • Visual Studio .NET Editions
      • Standard
      • Professional
      • Enterprise Developer
      • Enterprise Architect
  • 12. Writing Visual Basic Projects
    • There is a three-step process when writing a Visual Basic application—you set up the user interface , define the properties and then create the code
    • Planning
      • Design the User Interface
      • Plan the Properties
      • Plan the Basic Code; follow the language syntax rules; use pseudocode (English expression or comment describing action) then you move on to
    • Programming (and use the same three step process)
      • Define the User Interface
      • Set the properties
      • Write the Basic code
  • 13. VB Application Files
    • One Solution File—think of one solution file equals one project .sln
    • Solution User Options File .suo
    • Form Files .vb
    • Resource File for the Form .resx
    • Project Files .vbproj
    • Project User Options File .vbproj.user
    • Application configuration File .app.config
    Once a project is run several more files are created by the system. The only file that is opened directly is the solution file.
  • 14. Visual Studio Environment
    • The Visual Studio environment is where you create and test your projects-in Visual Studio it is called an
    • Integrated Development Environment (IDE)
      • consists of various tools including:
        • Form Designer
        • Editor for entering code
        • Compiler
        • Debugger
        • Object Browser
        • Help facility
  • 15. Default Environment Settings
    • Visual Studio 2005 provides a new option that allows the programmer to select the default profile for the IDE
  • 16. The IDE Initial Screen The Visual Studio IDE with the Start Page open, as it first appears in Windows XP, without an open project.
  • 17. IDE Main Window Toolbars Document Window Form Designer Solution Explorer Window Properties Window Toolbox Help
  • 18. ToolBox
    • Y ou can scroll to view more controls
    • To sort the tools in the toolbox:
      • Right-click the toolbox and select
      • Sort Items Alphabetically from the context menu (shortcut menu).
  • 19. Modes
    • Design Time--used when designing the user interface and writing code
    • Run Time--used when testing and running a project
    • Break Time- -if/when receiving a run-time error or pause error
    “ Look at the Title Bar”
  • 20. Writing Your First Visual Basic Project Setting Up the Project 1 2 3 Hello World Project
  • 21. Planning the Project
    • Design the user interface
      • Set up the form
        • Resize the form
        • Place a label and a button
        • control on the form using the
        • toolbox
        • Lock the Controls in place
    • After the user interface is
    • designed, the next step is to
    • set the properties
  • 22. Setting Properties
    • Label 1
      • Name messageLabel
      • Text leave blank
    • Button 1
      • Name pushButton
      • Text Push Me
    • Button 2
      • Name exitButton
      • Text Exit
    • Form
      • Name helloForm
      • Text Hello World by your name
  • 23. Setting the Form Properties
    • The default startup object is Form1
    • The name of the form should always be changed to adhere to naming rules
    • The properties window shows the files properties
  • 24. Writing the Code
    • While the project is running the user can perform actions
    • Each action by the user causes an event to occur
    • Write code for the events you care about; the events you want to respond to with code
    • Code is written as event procedures
    • VB will ignore events for which you do not write code
    • VB will automatically name event procedures as the object name, an underscore(_) and the name of the event
  • 25. More on Writing the Code
    • When writing the code for your first project you will use the following:
      • Remark Statement
      • Assignment Statement
      • Ending a Program
      • Editor Window
  • 26. Remark Statement
    • Also known as Comment, used for documentation; every procedure should begin with a remark statement providing explanation
    • Non-executable
    • Automatically colored Green in Editor
    • Begins with an apostrophe ( ' )
      • On a separate line from executable code
      • At the right end of a line of executable code
    ' Display the Hello World message.
  • 27. Assignment Statement
    • Assigns a value to a property or variable
    • Operates from right to left- the value appearing on the right side of the equal sign is assigned to the property named on the left of the equal sign
    • Enclose text strings in quotation marks (" ")
    messageLabel.Text=" Hello World "
  • 28. Ending a Program
    • Methods always have parentheses (this will help you distinguish them from Properties which never have parentheses)
    • To execute a method of an object you write:
    • Object.Method()
    • Current Form may be referenced as Me
    Me.Close( )
  • 29. Editor Window
    • Declarations Section
    • Class list
    • Method list
  • 30. Run, Save, Modify, Print, Test, Debug and Execute
    • Run Project
      • Debug Menu, Start
      • Start (F5)
        • Start Without Debugging (CTRL+F5)
    • Save Project - File Menu, Save All
    • Modify Project if needed
    • Print the Code
    • Correct any Errors and Rerun
    • When you start executing your program, the first step is called compiling , which means that the VB statements are converted to Microsoft Intermediate Language (MSIL). Your goal is to have no errors during the compile process: a clean compile .
    "Help is always available from the Help Menu or by pressing F1."
  • 31. Print the Code
    • File Menu, Print
    • Prints complete code listing
    • Uses arrow symbol to denote line continuation
  • 32. Finding and Fixing Errors
    • Syntax Errors
      • Breaks VB’s rules for punctuation, format or spelling
      • Smart editor finds most syntax errors, compiler finds the rest
      • The editor identifies a syntax error with a squiggly blue line and you can point to an error to pop up the error message.
      • You can display the Error List window and line numbers in the source code to help locate the error lines.
    • Run-Time Errors
      • Statements that fail to execute such as impossible arithmetic operations
    • Logic Errors
      • Project runs but produces incorrect results
  • 33. Naming Rules and Conventions
    • Have a set of standards and always follow them
    • No spaces, punctuation marks or reserved words
    • Use camel casing
      • Examples
        • messageLabel
        • exitButton
        • dataEntryForm
        • paymentAmountTextBox
  • 34. Recommended Naming Conventions for VB Objects introPageSoundPlayer SoundPlayer ingredientsListBox ListBox bookListComboBox ComboBox landscapePictureBox PictureBox temperatureVerticalScrollBar Vertical Scroll Bar rateHorizontalScrollBar Horizontal Scroll Bar printSummaryCheckBox CheckBox boldRadiobutton Radio button paymentAmountTextbox TextBox totalLabel Label exitButton Button dataEntryForm Form Example Object Class
  • 35. Visual Studio Help Additional Info (1 of 2)
    • Visual Studio has an extensive Help facility,
    • Filter MSDN help to display VB topics only
    • Run MSDN from hard drive, CD or Web
    • You can access MSDN on the Web at http://msdn.microsoft.com
    • The Help system display is greatly changed and improved in Visual Studio 2005. You view the Help topics in a separate window from the VS IDE, so you can have both windows open at the same time .
  • 36.
    • When you choose How Do I , Search , Contents , Index , or Help Favorites from the Help menu, a new window opens on top of the IDE window. You can switch from one window to the other, or resize the windows to view both on the screen if your screen is large enough.
    Visual Studio Help Additional Info (2 of 2)