IFSC1202 Exam #1, Summer 2000 Name______________________________
- Fill in each blank with one of the words or symbols below (you can use a word more than once):
: _ alternation attribute automatically behavior controls data different editor enclose event executed exit expression form functions IDE keyboard keyword layout loading looping module mouse names nested objects options paint pre-defined procedure(s) project property protected run selection String subroutines
Visual Basic programs are created in an ___________ that allows programmers to create, ___________ and debug Visual Basic programs conveniently. This integrated development environment provides features to manage ___________ files, to visually ___________ the GUI, and to easily modify any ___________ of any project component. Moreover, the IDE includes a context-sensitive code ___________ for writing VB processing routines, and it can execute the ___________within the IDE, permitting one-click testing and debugging. VB provides an extensive library of ___________routines and controls and these standard features can be easily augmented by importing third-party components. VB projects are modularized based on___________ and code files. Code, data, or control components in one module can be accessed by code in a ___________module or ___________ from such access. The VB programming language is comprised of numerous statements, each identified by the ___________that begins the statement. Each statement is usually written on a separate line, although by using the statement separator symbol ___________or the line continuation character ___________the one-line/one-statement format can be modified. Statements in a module either declare___________, set ___________, or are parts of procedures that do processing. VB permits four kinds of ___________: subroutines, ___________, ___________ procedures, or methods associated with VB objects. While many functions and methods are built into the language, the programmer can custom code___________, functions, or ___________ procedures that match the application requirements. The programmer can even code new objects and provide them with properties and methods so that they can be used alongside the built in objects. The VB code used by a project is organized by form, so that each form file includes the code for all of the ___________attached to that form as well as the code for the events associated with those ___________. Code modules hold ___________ and ___________declarations that are not closely connected to a specific form. VB supports many kinds of ___________ and automatically converts values of one ___________ type to the nearest value of a different ___________ type. ___________ items in VB may be declared as Boolean, Byte, ___________, Date, or one of many different numeric ___________ types. Whenever ___________ items of different types must be combined, VB will automatically convert one of the items so that the combining operation will be performed on a common type. Because all objects, procedures, and data items are ___________named when they are created, any ___________of any component of a VB project can be referenced by VB code. This permits new values for data items and some object properties to be assigned by the program, making the appearance of the object or the ___________of the program change in response to user input. Indeed, VB programs are responsive to large number of user-initiated events via ___________or ___________ and also system events. VB programs respond to data input directly from the user or retrieved from disk or network. All procedures are coded with flow control statements that permit ___________of processing paths and ___________ in addition to invocation of externally packaged procedures. Processing paths are alternated by evaluating a data ___________and using the result to select or omit certain statements. VB provides the IF/THEN/ELSE ___________structure, the IF/ELSEIF structure, and the SELECT CASE/CASE structure, any of which can be used in combination or___________. For looping VB has several versions of the DO/LOOP structure, the WHILE, and the FOR/NEXT structures that can also be used in combination or nested. Each of these flow control structures ___________ a block of statements in their bodies that are selectively or repeatedly ___________until the condition to___________ the structure are met. Specific statements initiate and terminate the structure and thus make clearly visible both the statements of the body and the processing step performed by the structure. These structures are entered from the top (following the execution of the previous statement or flow control block) and exited to the bottom (causing the following statement or flow control block to begin execution). When an external ___________ is invoked, processing of statements at the point of invocation ceases temporarily while the ___________ is executed, and when the execution is complete, processing of statements continues at the point following the invocation. When a VB program begins to execute, the code describing the GUI is executed to ___________ the user’s screen, and any code associated with the ___________ of the initial form is performed and then the program waits for the user to initiate interaction with any of the ___________displayed on the screen.
(26 pts. .5 pt. @ with full credit for ?) correct only the ones you missed
- Circle T or F to indicate that the statement is either True or False (15 pts) give reason or cite page #.
T F The tool bar contains the control icons.
T F A form’s sizing handles are always enabled.
T F The names number and NuMbEr refer to the same variable.
T F The modulus operator, Mod can be used with decimal variables.
T F Declarations can appear almost anywhere in the body of an event procedure.
T F The body of a DoUntil is only executed if the loop continuation test is False.
T F The data type Single and the data type Long each require four bytes, consequently they represent the same
range of numeric values.
T F The Case Else statement is required in the Select Case structure.
T F The expression (x>y And a<b) is True if either x>y is True or a<b is True.
T F A module-level variable is declared in the general declaration.
T F Keyword To is required when writing a For/Next loop.
T F A Function is invoked by using its name in an expression, but to invoke a Subprocedure you must write a Call statement.
T F A program that uses the Rnd function can be run repeatedly and each time it will produce the same values.
T F Module-level variables are automatically in the storage class Static.
T F Local variables cannot be declared Public but they can be declared Static.
- a. Explain on the right why the following subroutine is called an event procedure: (2 pts.)
Private Sub cmdButton_Click()
Dim b As Integer, e As Integer, a As Integer, r As Integer
r = 1
b = InputBox("Enter a number:", "One")
e = InputBox("Enter a number:", "Two")
For a = 1 To e
r = r * b
Next a
lblDisplayValue.Caption = "Mystery is " & r
End Sub
b. Draw a sketch of how the form
looks after this code has executed as
far as this code reveals its formatà
(3 pts.)
c. Sketch what the form looks like
during the execution of this code
(when the user is typing)à
(3 pts.)
d. If the two numbers input are 5 and 7,
what does the program produce?
(2 pts.)
Write statements to accomplish each of the following"
a. if the value of count is positive, write a message on the form: (2 pts.)
b. if dayOfMonth indicates a new month, display today’s date on the label lblAttention (2 pts.)
c. use Integer variables sum and count to compute the sum of the odd numbers from 1 to 99 (3 pts.)
d. given Integer variables first and second place the larger value in first. (3 pts.)
e. write a function procedure that receives two Integer arguments and returns the larger.(4 pts.)
- Give the value and type of each of the following expressions (assume x=3.14 and y=2.7x104:
a. 13 \ x b. y Mod 10
c. 3 ^ -2 d. "+" & x
e. Not 3 f. 5 Or (y<x)
g. 2 * 4 Mod 3 + 6 \ 3 ^ -1 h. 8 + 10 \ 2 * 5 – 2 ^ 3 / 4
- Name as many properties as you can that a button object has (whose names are in the button property table): (3=1pt, each additonal 2 = additional pt up to a max of 4 (for seven))
- Construct a trace of the following program by filling out the table, making a new row entry every time any variable changes value. Below the table show what is printed: (5 pts. for trace, 3 pts for output)
Dim p As Integer, c As Integer, m As Integer p c m
For p = 0 to 4
While c < p
Select Case ( p + c – 1)
Case –1 Or 0
m = m + 1
Case 1, 2, 3
m = m + 2
Case Else
m = m + 3
End Select
Print m;
c = c + 1
Wend
Next p
Print
Print m
- Consider the function
Private Function Numbers() As Integer
Numbers = 3 + (Int(3*Rnd()))*(3+Int(2*Rnd()))
End Function
- Write the event procedure that will print the
value of Numbers() 100 times on a form when
a button is pressed. à
Write all the statements of the procedure
including the header (4 pts.)
b. What are the values that will be printed
repeatedly at random? (2 pts.)
c. Which value will be printed almost twice
as often as any of the other values? (1 pt)