Download presentation
Presentation is loading. Please wait.
Published byCaren Carpenter Modified over 9 years ago
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
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic 2010 5 th Edition
3
Programming with Microsoft Visual Basic 2010, 5 th Edition Previewing the Splash Screen 3 Figure 1-1 Splash screen for the Country Charm Inn
4
Programming with Microsoft Visual Basic 2010, 5 th Edition Lesson A Objectives 4 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application 5 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 6 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 Window Layout Click Yes at prompt to restore default layout Can also select a different window layout Using Tools, Settings, on the menu bar
7
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 7 Figure 1-2 Microsoft Visual Studio 2010 Professional startup screen
8
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 8 Figure 1-3 Microsoft Visual Basic 2010 Express startup screen
9
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 9 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 10 Figure 1-4 Options dialog box
11
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 11 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 12 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 13 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Figure 1-5 Completed New Project dialog box in Visual Studio 2010 Professional The Splash Screen Application (cont’d.) 14
15
Programming with Microsoft Visual Basic 2010, 5 th Edition Figure 1-6 Completed New Project dialog box in Visual Studio 2010 Professional The Splash Screen Application (cont’d.) 15
16
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 16 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Figure 1-8 Current status of the windows in the IDE The Splash Screen Application (cont’d.) 17
18
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 18 The Windows Form Designer window Used to create graphical user interface (GUI) Figure 1-9 Windows Form Designer Window
19
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 19 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 20 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 21 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 22 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 23 Figure 1-11 Properties window
24
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 24 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The Splash Screen Application (cont’d.) 25 Figure 1-12 Form file’s name shown in various locations
26
Programming with Microsoft Visual Basic 2010, 5 th Edition Properties of a Windows Form 26 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Properties of a Windows Form (cont’d.) 27 Figure 1-13 Properties window showing a partial listing of the form’s properties
28
Programming with Microsoft Visual Basic 2010, 5 th Edition Properties of a Windows Form (cont’d.) 28 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Properties of a Windows Form (cont’d.) 29 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Properties of a Windows Form (cont’d.) 30 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Properties of a Windows Form (cont’d.) 31 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Properties of a Windows Form (cont’d.) 32 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Properties of a Windows Form (cont’d.) 33 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Setting and Restoring a Property’s Value 34 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Setting and Restoring a Property’s Value (cont’d.) 35 Figure 1-14 Status of the form in the IDE
36
Programming with Microsoft Visual Basic 2010, 5 th Edition Saving a Solution 36 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Closing the Current Solution 37 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Opening an Existing Solution 38 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Exiting Visual Studio 2010 or Visual Basic 2010 Express 39 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Lesson A Summary 40 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Lesson B Objectives 41 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Lesson B Objectives (cont’d.) 42 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The Toolbox Window 43 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The Toolbox Window (cont’d.) 44 Figure 1-15 Toolbox window showing the purpose of the Label tool
45
Programming with Microsoft Visual Basic 2010, 5 th Edition The Label Tool 45 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Figure 1-17 Label control added to the form Figure 1-16 Label tool being dragged to the form 46
47
Programming with Microsoft Visual Basic 2010, 5 th Edition Changing a Property for Multiple Controls 47 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
Programming with Microsoft Visual Basic 2010, 5 th Edition Changing a Property for Multiple Controls (cont’d.) 48 Figure 1-18 Label controls selected on the form
49
Programming with Microsoft Visual Basic 2010, 5 th Edition Using the Format Menu 49 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
Programming with Microsoft Visual Basic 2010, 5 th Edition The PictureBox Tool 50 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
51
Programming with Microsoft Visual Basic 2010, 5 th Edition Figure 1-19 Open task list for a picture box Figure 1-20 Completed Select Resource dialog box 51
52
Programming with Microsoft Visual Basic 2010, 5 th Edition The PictureBox Tool (cont’d.) 52 Figure 1-21 Image shown in the picture box
53
Programming with Microsoft Visual Basic 2010, 5 th Edition The Button Tool 53 Button tool: Used to create button control Button control: Used to perform action when clicked Examples: OK and Cancel buttons Common means of exiting a Windows application Exit option on File menu Exit button
54
Programming with Microsoft Visual Basic 2010, 5 th Edition Starting and Ending an Application 54 Startup form: Displays when application is first started Project Designer window: Specifies startup form or executable code to be run Right-click My Project in Solution Explorer window and then click Open Or, click Project on menu and then click Properties Application tab: Specify startup form
55
Programming with Microsoft Visual Basic 2010, 5 th Edition Starting and Ending an Application (cont’d.) 55 Figure 1-22 Application pane in the Project Designer window
56
Programming with Microsoft Visual Basic 2010, 5 th Edition Starting and Ending an Application (cont’d.) 56 Executable file: File that can be run outside of the IDE File name ends with.exe Automatically created when starting Visual Basic application Two ways to start application in IDE Click Debug on menu bar and then click Start Debugging Press F5 key
57
Programming with Microsoft Visual Basic 2010, 5 th Edition Starting and Ending an Application (cont’d.) 57 Figure 1-23 Result of starting the splash screen application
58
Programming with Microsoft Visual Basic 2010, 5 th Edition The Code Editor Window 58 Event: User action such as double-clicking Event procedure: Set of program instructions that are processed when event occurs Code Editor window Provides templates for creating event procedures To open Code Editor window Right-click form and then click View Code
59
Programming with Microsoft Visual Basic 2010, 5 th Edition The Code Editor Window (cont’d.) 59 Figure 1-24 Code Editor window opened in the IDE
60
Programming with Microsoft Visual Basic 2010, 5 th Edition The Code Editor Window (cont’d.) 60 To collapse or expand a region of code in the Code Editor window Click minus box to collapse code Click plus box to expand code Figure 1-25 Code collapsed in the Code Editor window
61
Programming with Microsoft Visual Basic 2010, 5 th Edition The Code Editor Window (cont’d.) 61 Class Name list box Lists names of objects included in UI Method Name list box Lists appropriate events for selected object To select a control’s event in code editor window Select class name first and then select method name Syntax Rules of programming language
62
Programming with Microsoft Visual Basic 2010, 5 th Edition The Code Editor Window (cont’d.) 62 Procedure header First line in code template for event procedure Procedure footer Last line in code template for event procedure Keyword Word that has special meaning in programming language Color-coded in IDE
63
Programming with Microsoft Visual Basic 2010, 5 th Edition The Code Editor Window (cont’d.) 63 Sub procedure Block of code that performs a specific task Keywords in a sub procedure block Sub: starts a sub procedure Private: restricts the use of the procedure to the form where it appears End Sub: indicates the end of a sub procedure Event sub procedure names include object name and event name Example: btnExit_Click
64
Programming with Microsoft Visual Basic 2010, 5 th Edition The Me.Close() Instruction 64 Method: Predefined procedure Can be called (or invoked) when needed Me.Close() method Causes current form to close If it is only form in application, the application terminates IntelliSense feature: Provides appropriate selections as pop- up lists Type first few letters of choice Then use arrow keys to select an item in list
65
Programming with Microsoft Visual Basic 2010, 5 th Edition Figure 1-27 List displayed by the IntelliSense feature Figure 1-28 Completed Click event procedure for the btnExit control 65
66
Programming with Microsoft Visual Basic 2010, 5 th Edition Lesson B Summary 66 To add a control to a form, use tool from toolbox Use Label control for text that user cannot edit Can set properties of multiple controls simultaneously To start and stop an application in IDE, use the Debug menu choice Use Code Editor window to display object’s event procedures Me.Close() method closes the current form at run time
67
Programming with Microsoft Visual Basic 2010, 5 th Edition Lesson C Objectives 67 After studying Lesson C, you should be able to: Set the properties of a timer control Delete a control from the form Delete code from the Code Editor window Code a timer control’s Tick event procedure Prevent the user from sizing a form Remove and/or disable the form’s Minimize, Maximize, and Close buttons Print an application’s code and interface
68
Programming with Microsoft Visual Basic 2010, 5 th Edition Using the Timer Tool 68 Splash screens typically close automatically Do not usually contain Exit button Timer control removes splash screen Timer tool: Used to create a timer control Timer control Processes code at regular time intervals Does not appear on the user interface at run time Interval property specified in milliseconds Enabled property allows timer to run if set to True
69
Programming with Microsoft Visual Basic 2010, 5 th Edition Using the Timer Tool (cont’d.) 69 Tick event Occurs each time an interval has elapsed Condition: Timer must be running (enabled) Add code into Tick event procedure Code will be run when Tick event occurs Component tray Special area below form design area in IDE Stores controls not visible in user interface at run time
70
Programming with Microsoft Visual Basic 2010, 5 th Edition Using the Timer Tool (cont’d.) 70 Figure 1-31 Timer control placed in the component tray
71
Programming with Microsoft Visual Basic 2010, 5 th Edition Setting the FormBorderStyle Property 71 FormBorderStyle property Determines the border style of a form Example settings Sizable: Allows user to change form’s size by dragging its borders at run time FixedSingle: Fixed, thin border line None: No border
72
Programming with Microsoft Visual Basic 2010, 5 th Edition The MinimizeBox, MaximizeBox, and ControlBox Properties 72 MinimizeBox property: Determines whether Minimize button appears on form’s title bar MaximizeBox property: Determines whether Maximize button appears on form’s title bar ControlBox property: Determines whether title bar appears on form Splash screens typically do not contain title bar To remove title bar, delete contents of form’s Text property
73
Programming with Microsoft Visual Basic 2010, 5 th Edition The MinimizeBox, MaximizeBox, and ControlBox Properties (cont’d.) 73 Figure 1-33 Completed splash screen
74
Programming with Microsoft Visual Basic 2010, 5 th Edition Printing the Application’s Code and Interface 74 Print a copy of application’s code and user interface Helps you understand and maintain application To print code Code editor window must be active (current) window Print options Hide collapsed regions Include line numbers
75
Programming with Microsoft Visual Basic 2010, 5 th Edition Printing the Application’s Code and Interface (cont’d.) 75 Figure 1-34 Print dialog box
76
Programming with Microsoft Visual Basic 2010, 5 th Edition Lesson C Summary 76 Timer control processes code at specified intervals Form’s MinimizeBox and MaximizeBox properties enable or disable Minimize and Maximize buttons on form Form’s ControlBox property determines whether icon and control buttons appear in title bar Form’s BorderStyle property controls appearance of the form’s border Print Visual Basic code from Code Editor window Print user interface from designer window
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.