You are on page 1of 5

Chapter 2 - Critical Thinking

1. Describe how the windows, components, and features of the


Visual Basic IDE are used to develop, run, and debug an application.

The IDE or Integrated Development Environment is the workspace


given to users to create and code an application in Visual Basic. It
contains the menu bar, toolbar, design window, toolbox, solution
explorer and the properties window. The menu bar contains the
names of drop down menus that have commands. The toolbar has
buttons that represent different actions. The design window shows
the application interface. The toolbox contains grouped controls used
to create objects on the interface. The solution explorer is used to
switch between the code and design windows. Finally, the properties
window lists the properties of the selected object. Code is typed into
the text on the code window and when it is ready to be debugged and
tested, the debug tab on the menu bar is clicked, and Start
Debugging is clicked.

2. Indicate what would be displayed if each of these expressions


were assigned to a label:
a) 10 + 3 6
7
b) 2^3+5*4
28
c) 4+3*2
10
d) 2 + 9 ^ (1/2)
5
e) 15 * 2 + 4
34
f) 15 * (2 + 4)
90
g) 2+4/2+1
5
h) 53^2+1
-3
i) 15 / 3 + 2
7
j) 6 + 3 2
6+32
k) 2+9^1/2
6.5

l) 5 3 ^ (2+1)
-22
3. Explain the term event driven.
The term event driven means code is executed in response to events. An
event occurs when a user interacts with an object; for example, the clicking
of a button closes an application. The event is the user clicking the button,
and the button is the object.

4. List the controls presented in this chapter and explain if and how the
user can interact with each one.
The radio button and button are used for the user to click, the label is used
for the display of text, menu strip to add a strip on the top of the program
that contains menu items, and group box control to group objects together
(such as radio buttons).
5. List at least one difference in the way a form looks between the Design
window and at run time.
One difference between a form at run time and a form in the Design window
is that at run time, you cannot change anything in the program; whereas in
the Design menu: properties can be changed, labels can be moved around,
etc.

6. List two ways to terminate a running program.


Two ways to terminate a running program: click the x button on the top
right of the form or code an event to occur when a button is clicked to exit
the program.

7. Explain the difference between the (Name) and Text properties of a


control.
The difference between the (Name) and Text properties is that the Text
properties is what the control shows on it (for example the text on a button
that displays its name). The (Name) property is just the name of the control,
and it is used in the coding process to assign events to the control. The
computers reads the (Name) property and a person reads the Text property.

8. Why is it better to type the statement Me.lblMessage.Text = Hello


world! rather than lbl.Message.Text = Hello world!
It is better to type the statement with the Me. command because it refers
to the Form object.

9. Write the statements needed for the Click event procedures of radSum
and radDifference bases on the following application. Assume the first
lavel is named lblMessage and the second is named lblresult:
A: radSum
Me.lblResult.Text = 5 + 3
Me.lblMessage.Text = The sum of x and y is 8

B: radDifference
Me.lblResult.Text = 5-3
Me.lblMessage.Text = The difference of x and y is 2

10. Explain the error(s) in the following comments:


This is my first program
9/9/12

Display greeting Hi There!


There is no apostrophe in front of the 9/9/12 to indicate it is a comment.
Also, there is an apostrophe in front of Display greeting, meaning the Hi
There! is also a comment.

11. Determine if each of the following are true or false. If false,


explain why.
a) A Visual Basic application consists of a single file.
False, a Visual Basic application consists of many files.
b) A Windows application includes at least one form.
True
c) The Text property of a form defines what is displayed in its title bar.
True
d) The properties of an object can only be set in the properties window.
False, it can be set at run time with an assignment statement.
e) Text displayed in a label can be changed by the user.
False, the text is inputed by the programmer; the user cannot change
it.
f) A MenuItem object can have a Click event procedure.
True

g) A MenuStrip component can have only one MenuItem object.


False, a MenuStrip can have numerous MenuItem objects.
h) Each line of program code is called an object.
False, an object is a variable of a class. A line of code is called a
statement.
i) Visual Basic is an object-oriented programming language.
True
j) Program code is typed into the Design window.
False, code is typed into the code window.
k) Buttons in the toolbox are used to switch between the Code and
Design windows.
False, buttons in the solution explorer window are used to switch
between the Code and Design windows.
l) Click is an example of an event.
True
m) Private indicates that a procedure can be accessed outside of the
Form1 class.
False, the private indicates that a procedure can NOT be accessed
outside of a Form1 class.
n) Options displayed in the IntelliSense list vary depending on what is
typed before the dot.
True
o) An assignment statement is used to change a value at run time.
True
p) More than one radio button in a set can be selected at the same time.
False, only one may be selected at once.
q) The only purpose of a GroupBox object is to display a title for a set of
RadioButton objects.
False, a GroupBox is also used to group radio buttons that are related.
r) Comment affect the way an application runs.
False, comments do not affect the way an application runs, and they
are just used to explain what the program does/what it is doing.
s) Multiline comments are created by placing a question mark (?) at the
beginning of each line.
False, you use an apostrophe on each line to create a multiline
comment.
t) Code conventions are a set of guidelines for writing an application.
True

You might also like