1 / 76

About the Presentations

About the Presentations. The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning of each presentation. You may customize the presentations to fit your class needs.

herald
Télécharger la présentation

About the Presentations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. About the Presentations • The presentations cover the objectives found in the opening of each chapter. • All chapter objectives are listed in the beginning of each presentation. • You may customize the presentations to fit your class needs. • Some figures from the chapters are included. A complete set of images from the book can be found on the Instructor Resources disc.

  2. Programming with Microsoft Visual Basic 2010 5th Edition Chapter One An Introduction to Visual Basic 2010

  3. Previewing the Splash Screen Figure 1-1 Splash screen for the Country Charm Inn

  4. Lesson A Objectives After studying Lesson A, you should be able to: • Start and customize Visual Studio 2010 or Visual Basic 2010 Express • Create a Visual Basic 2010 Windows application • Manage the windows in the IDE • Set the properties of an object • Restore a property to its default setting • Save a solution • Close and open an existing solution

  5. The Splash Screen Application • In this chapter, you create a splash screen using Visual Basic 2010 • Visual Basic 2010 is available as: • A stand-alone product • Visual Basic 2010 Express • Part of Visual Studio 2010

  6. The Splash Screen Application (cont’d.) • Starting Visual Studio 2010 or Visual Basic 2010 Express • Click Start and point to All Programs • Select one of two environments • Microsoft Visual Studio 2010 • Microsoft Visual Basic 2010 Express • Click Window on the menu bar • Click Reset WindowLayout • Click Yes at prompt to restore default layout • Can also select a different window layout • Using Tools, Settings, on the menu bar

  7. The Splash Screen Application (cont’d.) Figure 1-2 Microsoft Visual Studio 2010 Professional startup screen

  8. The Splash Screen Application (cont’d.) Figure 1-3 Microsoft Visual Basic 2010 Express startup screen

  9. The Splash Screen Application (cont’d.) • Configure Visual Basic 2010 Express • Click Tools on menu bar, point to Settings, then Expert Settings • Click Tools on menu bar, then Options, and deselect Show all settings if necessary • Click Projects and Solutions node • Select options as shown in Figure 1-4 on following slide, then click OK

  10. The Splash Screen Application (cont’d.) Figure 1-4 Options dialog box

  11. The Splash Screen Application (cont’d.) • Splash screen is a Windows application • Has Windows user interface • Windows applications composed of solutions, projects, and files • Solution: container that stores application’s projects and files • Can contain several projects • Project: container storing associated files

  12. The Splash Screen Application (cont’d.) • Creating a Windows application • Click File on menu bar, then click New Project • Click Visual Basic in the Installed Templates list • If using Visual Studio, expand Visual Basic node and then click Windows • Click Windows Forms Application • Change name to Splash Project • Click Browse button to open Project Location dialog box • Click VB2010\Chap01 folder • Click Select Folder to close dialog box

  13. The Splash Screen Application (cont’d.) • Creating a Windows application (cont’d.) • If necessary, select Create directory for solution • In New Project dialog box • Change name to Splash Solution • Completed New Project dialog boxes shown in Figures 1-5 and 1-6 on following slides • Click OK

  14. The Splash Screen Application (cont’d.) Figure 1-5 Completed New Project dialog box in Visual Studio 2010 Professional

  15. The Splash Screen Application (cont’d.) Figure 1-6 Completed New Project dialog box in Visual Studio 2010 Professional

  16. The Splash Screen Application (cont’d.) • Managing the Windows in the Integrated Development Environment (IDE) • To open a window • Click View on menu bar, click Properties Window • Or mouseover Solution Explorer tab if auto-hidden • To close a window • Use Close button on window’s title bar • To minimize window to tab • Click Auto Hide (push-pin) button on Solution Explorer window

  17. The Splash Screen Application (cont’d.) Figure 1-8 Current status of the windows in the IDE

  18. The Splash Screen Application (cont’d.) • The Windows Form Designer window • Used to create graphical user interface (GUI) Figure 1-9 Windows Form Designer Window

  19. The Splash Screen Application (cont’d.) • Windows Form object (or Form) • Foundation for UI in a Windows application • Create UI by adding objects • Buttons • Text boxes • Title bar contains default caption • Also minimize, maximize, and close buttons

  20. The Splash Screen Application (cont’d.) • The Solution Explorer window • Displays list of projects contained in current solution • And items contained in each project Figure 1-10 Solution Explorer window

  21. The Splash Screen Application (cont’d.) • Source file • File containing program instructions (code) • Form file • Contains code associated with a form • First form’s code stored in Form1.vb • Second form’s code stored in Form2.vb • And so on

  22. The Splash Screen Application (cont’d.) • Properties • Attributes of object that determine its appearance and behavior • Properties window lists object’s properties • Object box • Contains name of selected object • Properties list • Helps identify and access properties • Settings box • Shows current values of properties

  23. The Splash Screen Application (cont’d.) Figure 1-11 Properties window

  24. The Splash Screen Application (cont’d.) • Using the Properties window to change a form file’s name • Click File Name in Properties list • Type Splash Form.vb • .vb extension identifies file as source file • Press Enter

  25. The Splash Screen Application (cont’d.) Figure 1-12 Form file’s name shown in various locations

  26. Properties of a Windows Form • To view form properties • Click the form in the designer window • Click Alphabetical button to list alphabetically • Class definition • Specifies attributes and behaviors • Namespace • Code defining group of classes • Dot member access operator • Specifies hierarchy of namespaces • Example: System.Windows.Forms.Form

  27. Properties of a Windows Form (cont’d.) Figure 1-13 Properties window showing a partial listing of the form’s properties

  28. Properties of a Windows Form (cont’d.) • Name property • Refers to object in code • Each object has unique name • Must begin with letter • Contains only letters, numbers, and underscores • Hungarian notation: Naming convention • First three characters represent object’s type • Remaining characters represent object’s purpose • Name uses camel case (for camel’s hump) • Example: frmCalculateTaxes

  29. Properties of a Windows Form (cont’d.) • To change form’s name • Drag Properties window scroll box to top of vertical scroll bar • Click Name in Properties list • Type frmSplash and press Enter • Asterisk appears to indicate unsaved changes

  30. Properties of a Windows Form (cont’d.) • Text property • Controls text displayed in form’s title bar • Also appears on application’s taskbar button • Default value is Form1 • Should always be changed to meaningful value • To set form’s Text property • Click Text in the Properties list • Type Country Charm Inn and press Enter

  31. Properties of a Windows Form (cont’d.) • The StartPosition property • Determines form’s initial position on screen • Splash screen’s StartPosition • Typically appears in the middle of the screen • To center form on screen • Click StartPosition in Properties list • Then click list arrow in settings box • Click CenterScreen

  32. Properties of a Windows Form (cont’d.) • Font property • Determines type, style, and size of the font used on the form • Font indicates general shape of characters • Size is measured in points • To set form’s Font property • Click Font in Properties list, and click ellipsis button in Settings box • Locate and click the desired font and size • Then click OK

  33. Properties of a Windows Form (cont’d.) • Size a form by selecting it and dragging sizing handles • Or select object and press and hold Shift key as you press desired arrow key • Size property • Two numbers separated by comma and space • First number represents width in pixels • Second number represents height in pixels

  34. Setting and Restoring a Property’s Value • BackColor property • Determines form’s background color • Set the value of a property using settings box in Properties list • To restore default value of a property • Right-click property name and click Reset

  35. Setting and Restoring a Property’s Value (cont’d.) Figure 1-14 Status of the form in the IDE

  36. Saving a Solution • Save solution at regular intervals • For example, every 10 minutes • Options for saving a solution • Click File on menu bar and then click Save All • Click Save All button on Standard toolbar

  37. Closing the Current Solution • Click File on menu bar and then click Close Solution • Impact of closing current solution • All projects and files contained within are closed • Close Solution option vs. Close option • Close option just closes IDE designer window

  38. Opening an Existing Solution • Only one solution can be open at any one time • Currently open solution closes before another opens • Names of solution files end with .sln • Opening an existing solution • Click File on menu bar and then click Open Project • Select appropriate solution file then click Open

  39. Exiting Visual Studio 2010 or Visual Basic 2010 Express • Options to exit from Visual Studio or Visual Basic Express • Use Close button on title bar • Click File on the menu bar and then click Exit

  40. Lesson A Summary • Start Visual Studio from Start button • Configure Visual Studio or Visual Basic Express • Create an application using File, New Project • Property values are set in Properties window of selected object • Form’s Text property displays caption in title bar • To save solution, click File, then Save All • To open existing solution, click File, then Open Project

  41. Lesson B Objectives After studying Lesson B, you should be able to: • Add a control to a form • Set the properties of a label, picture box, and button control • Select multiple controls • Center controls on the form • Open the Project Designer window

  42. Lesson B Objectives (cont’d.) • Start and end an application • Enter code in the Code Editor window • Terminate an application using the Me.Close() instruction • Run the project’s executable file

  43. The Toolbox Window • Class: Pattern from which object is created • Object: Instance with behaviors and attributes • Toolbox window (or toolbox) • Contains tools for designing user interface • Each tool represents class • Controls are instantiated using tools from toolbox • Controls: GUI objects that appear on a form

  44. The Toolbox Window (cont’d.) Figure 1-15 Toolbox window showing the purpose of the Label tool

  45. The Label Tool • Label tool: Used to create label control • Label control: Displays text that cannot be edited at run time • Name property: Unique name for control • Text property • Specifies value that appears in label control • Location property • Specifies location of control on form • Includes X value and Y value

  46. Figure 1-16 Label tool being dragged to the form Figure 1-17 Label control added to the form

  47. Changing a Property for Multiple Controls • Control inherits the Font attribute of the form • May want to change from default values • To simultaneously modify similar controls • Click one control and then press and hold Ctrl key • Click other similar control(s) in form • Or click and drag to group controls • Set property value in Properties list

  48. Changing a Property for Multiple Controls (cont’d.) Figure 1-18 Label controls selected on the form

  49. Using the Format Menu • Format menu: Options to manipulate form controls • Align: Aligns selected controls by left, right, top, or bottom borders • Make Same Size: Makes width and/or height of selected controls uniform • Center in Form: Centers one or more controls • Select as first control the one whose size or location you want to match • Called reference control

  50. The PictureBox Tool • PictureBox tool: Creates picture box control • Picture box control: Displays image on form • Task box: Lists tasks associated with picture box • Use task box to import image into project • Project’s resource file contains imported images

More Related