ITP 112 Final Exam Study Guide

ITD 112 Final Exam Study Guide

Spring 2008 – Mrs. Eaton

Work smart not hard. Spend a lot of time studying for this exam so you keep the grade you have earned so far this semester.

Good luck!

The exam will be about 60 hard multiple choice questions.

You will not have to write code on this exam, but you will have to be able to read code and understand it.

Study all of the following information.

There is a great glossary in Appendix D in your textbook. If you don’t know a key term, then look it up.

Chapter 7 Multiple Forms, Standard Modules, and Menus

Key Terms on page 472. Know the term and the definition or the purpose of the key word in the Visual Basic language.

7.1 Multiple Forms

Each Visual Basic application must have a startup object, either a form or a Sub procedure named Main. The Project’s Property Pages dialog box allows you to designate a project’s startup object.

The form that is the startup object automatically displays when then the project executes. Other forms are displayed by programming statements.

The form’s name is listed in the Property Window; the form’s file name is shown in the Solution Explorer window. The form’s file extension is .vb.

You can add a new form, rename an existing form, or remove a form from a Visual Basic application. You can also change the startup object to another form.

Before displaying a form, you must create an instance of the form. Then you must call a method (Show or ShowDialog) to display the form.

The Show method displays a form in modeless style. You can switch to other applications with the modeless style.

The ShowDialog method displays a form in modal style. When a modal form is displayed, no other form in the application can receive the focus until the modal form is closed. No other statements in the procedure that displayed the model form will execute until the modal form is closed.

A form’s Close method removes it from the screen and from memory. A form typically uses the Me keyword to call its own Close method, as in Me.Close().

The form’s Load event occurs just before a form is displayed for the first time.

A form’s Activated event occurs when the user switches to the form from another form or another application. The Activated event also occurs when a form is initially displayed, following the Load event.

The FormClosing event occurs when a form is in the process of closing, but before it has closed. This is a good place to include “Are you sure?” code.

The FormClosed event is triggered after a form has closed.

The Hide method makes a form or control invisible, but keeps the object in memory.

You can include code in the event handlers in response to any of the form events.

Code from one form can reference objects on a different form. You must fully qualify the name of the object by preceding it with the form name, followed by a period.

To make a form’s class-level variable available to statements outside the form, declare it with the Public keyword.

Although class-level variables are automatically declared private by the Dim keyword, you can explicitly declare them private with the Private keyword.

When a procedure declaration begins the Private keyword, the procedure may only be executed by statements in the same form.

After a form has been saved to a form file, it can be copied and used in other projects.

7.2 Standard Modules

A standard module contains code – declarations and procedure – that is used by other files in a project. Standard modules do NOT contain a form, and are not associated with a form and do not contain form event procedures.

You can designate a Sub procedure named Mainas an application’s startup object. Main must reside in a standard module. When the application runs, no form is initially displayed. Instead, the Sub procedure Main is executed.

A module-level variable is declared inside a module (between the Module and End Module statements), but not inside a Sub procedure.

A global variable is a module-level variable declared using the Public keyword.

You can use the same standard module in more than one project.

7.3 Menus

A menu system is a collection of commands organized in one or more deop-down menus.

The MenuStrip control lets you create a system of drop-down menus on any form.

You place a MenuStrip control on the form and then use the menu designer to create a menu system. The MenuStrip control displays in the Form’s Component Traybeneath the form.

An application’s menu system is constructed from ToolStripMenuItem objects. When you create menu items, name them with mnu prefix.

If you do not want the user to be able to select a menu item (grayed out), set the item’s Enabled property to False (either in design mode or in runtime code.)

When a menu’s Checked property equals True, a check mark appears on the menu next to the controls’ caption text.

A shortcut key is a key or key combination that causes a menu command to execute. For example, Ctrl + C is a shortcut for the Copy command.

A submenu displays a right arrow to its right.

A separator bar is a horizontal bar used to group commands on a menu.

You make a ToolStripMenuItem object respond to clicks by providing it a Click event handler.

A context menu is commonly called a pop-up menu. It displays when a user right-clicks a form or control.

Chapter 8 Arrays, Timers and More

Key Terms on pages 542 - 543. Know the definition or purpose of each key term.

8.1 Arrays

An array is group of variables using a single name. The variables within an array are called elements and are of the same data type.

Each variable in an array is accessed through its position in the array called an index or subscript. Position numbering for the index (or subscript) starts at zero.

When you declare an array you can specify the upper index (or subscript). For example to declare 7 elements, use
Dim intHours(6) as Integer

You can implicitly size an array by omitting the upper subscript in the declaration statement and providing an initialization list. An array initialization list is a set of numbers enclosed in a set of curly braces, with the data elements separated by commas. For example,
Dim intNumbers() As Integer = { 2, 4, 6, 8, 10, 12 }

Array elements are processed the same a regular variables, but when working with array elements; you must provide the index (subscript).

You can store an index (subscript) number in a variable and then use the variable as a subscript. This makes it easy to use a loop to cycle through an entire array, and performs the same operation on each element.

Visual Basic performs array bounds checking at runtime; it does not allow a statement to use a subscript outside the range for an array.

The For Each statement is a special loop designed specifically to access values in an array.

8.2 More about Array Processing

Arrays have a Length property that holds the number of elements in the array.

To sum the numbers stored in an array, use a loop with an accumulator variable that adds all the elements.

To average the numbers stored in an array, first sum all the values, and then divide the sum by the number of elements.

To copy the values in one array to another, use a loop to copy the individual elements.

You can create a parallel relationship between lists boxes, combo boxes, and arrays.

The sequential search algorithm uses a loop to examine the elements in array. It compares each element with the value being searched for, and stops when the value is found or the end of the array is encountered. If the value being search for is not in the array, the algorithm will unsuccessfully search to the end of the array.,

The Array.Sort method sorts the elements of an array in ascending order, which means the lowest value is stored in the first element and the highest valued is stored in the last element.

You can change the number of elements in an array at runtime with the ReDim statement. Use the Preserve keyword to keep the original values intact in the array.

8.3 Sub Procedures and Functions that Work with Arrays

Sub procedures and functions may be written to accept arrays as arguments.

Functions may also be written to return an array.

You can pass arrays by value or by reference. Warning, even if you pass an array using the ByVal keyword does not restrict a procedure from accessing and modifying the argument array’s elements.

8.4 Multidimensional Arrays

A single-dimension array has a single subscript.

A two-dimension is like an array of arrays and can be used to hold multiple sets of values. To declare a two-dimensional array, two sets of upper subscripts are required; the first one for the rows and the second one for the columns.

8.5 Focus on GUI Design: The Enabled Property, Timer Control, and Splash Screens

When a controls’ Enabled property is set to False, it is considered disabled, which means it cannot receive the focus, cannot respond to events generated by the user, and appears dimmed or grayed out on the form.

The Timer control is invisible at runtime. At design time it appears in the component tray. The standard prefix for a Time control’s name is tmr.

The Timer control responds to Tick events. When a Tick event occurs, the Tick event procedure is executed.

When the Timer control’s Enabled property is set to True, the Timer control responds to Tick events. When the Enabled property is set to False, the Timer control does not respond to Tick events and the code in the Tick event procedure does not execute.

The Timer control’s Interval property can be set to a positive nonzero value that is the number of milliseconds to elapse between Tick events. 1000 milliseconds is equal to a second.

Splash screens usually show logos and ensure the user that a slowly loading application is in the process of starting up.

8.6 Focus on GUI Design; Anchoring and Docking Controls

When a control is anchored to a form’s edge, the distance between the control’s edge and the form’s edge remains constant, even when the user resizes the form.

When a control is docked, it is positioned directly against one of the edges of a form. Additionally, the length or width of a docked control is changed to match the length or width of the form’s edge.

8.7 Random Numbers

The Random class contains methods that generate random sequences of numbers.

The Random.Next method returns the next random number in a series.

The Random.NextDouble method returns a random value between 0.0 and 1.0.

Mrs. EatonSpring 2008Page 1