Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic 2010 5 th Edition."— Presentation transcript:

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

2 Programming with Microsoft Visual Basic 2010, 5 th Edition Lesson B Objectives 2 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

3 Programming with Microsoft Visual Basic 2010, 5 th Edition Lesson B Objectives (cont’d.) 3 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

4 Programming with Microsoft Visual Basic 2010, 5 th Edition The Toolbox Window 4 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

5 Programming with Microsoft Visual Basic 2010, 5 th Edition The Toolbox Window (cont’d.) 5 Figure 1-15 Toolbox window showing the purpose of the Label tool

6 Programming with Microsoft Visual Basic 2010, 5 th Edition The Label Tool 6 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

7 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 7

8 Programming with Microsoft Visual Basic 2010, 5 th Edition Changing a Property for Multiple Controls 8 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

9 Programming with Microsoft Visual Basic 2010, 5 th Edition Changing a Property for Multiple Controls (cont’d.) 9 Figure 1-18 Label controls selected on the form

10 Programming with Microsoft Visual Basic 2010, 5 th Edition Using the Format Menu 10 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

11 Programming with Microsoft Visual Basic 2010, 5 th Edition The PictureBox Tool 11 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

12 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 12

13 Programming with Microsoft Visual Basic 2010, 5 th Edition The PictureBox Tool (cont’d.) 13 Figure 1-21 Image shown in the picture box

14 Programming with Microsoft Visual Basic 2010, 5 th Edition The Button Tool 14 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

15 Programming with Microsoft Visual Basic 2010, 5 th Edition Starting and Ending an Application 15 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

16 Programming with Microsoft Visual Basic 2010, 5 th Edition Starting and Ending an Application (cont’d.) 16 Figure 1-22 Application pane in the Project Designer window

17 Programming with Microsoft Visual Basic 2010, 5 th Edition Starting and Ending an Application (cont’d.) 17 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

18 Programming with Microsoft Visual Basic 2010, 5 th Edition Starting and Ending an Application (cont’d.) 18 Figure 1-23 Result of starting the splash screen application

19 Programming with Microsoft Visual Basic 2010, 5 th Edition The Code Editor Window 19 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

20 Programming with Microsoft Visual Basic 2010, 5 th Edition The Code Editor Window (cont’d.) 20 Figure 1-24 Code Editor window opened in the IDE

21 Programming with Microsoft Visual Basic 2010, 5 th Edition The Code Editor Window (cont’d.) 21 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

22 Programming with Microsoft Visual Basic 2010, 5 th Edition The Code Editor Window (cont’d.) 22 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

23 Programming with Microsoft Visual Basic 2010, 5 th Edition The Code Editor Window (cont’d.) 23 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

24 Programming with Microsoft Visual Basic 2010, 5 th Edition The Code Editor Window (cont’d.) 24 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

25 Programming with Microsoft Visual Basic 2010, 5 th Edition The Me.Close() Instruction 25 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

26 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 26

27 Programming with Microsoft Visual Basic 2010, 5 th Edition Lesson B Summary 27 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

28 Programming with Microsoft Visual Basic 2010, 5 th Edition True or False: The Me.Exit() method can be used to close the current form. 28

29 Programming with Microsoft Visual Basic 2010, 5 th Edition False 29

30 Programming with Microsoft Visual Basic 2010, 5 th Edition A(n) ____________________ control should be used to display text that the user cannot edit at run time. 30

31 Programming with Microsoft Visual Basic 2010, 5 th Edition Label 31

32 Programming with Microsoft Visual Basic 2010, 5 th Edition The rules of a programming language are called its ____________________. 32

33 Programming with Microsoft Visual Basic 2010, 5 th Edition Syntax 33

34 Programming with Microsoft Visual Basic 2010, 5 th Edition True or False: The Text property is only available for the label control 34

35 Programming with Microsoft Visual Basic 2010, 5 th Edition False 35


Download ppt "Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic 2010 5 th Edition."

Similar presentations


Ads by Google