Visual Basic Pointers

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Visual Basic Pointers: Multiple Choice & True or False

1. an event procedure
An Event Procedure is a set of instructions to be executed when a certain event happens.
For example, we can write an Event Procedure for when we push an “OK” button.
Almost everything in Visual Basic is either an Event Procedure or used by an Event Procedure.
2. Tab index
Tab Order – Sets the order in which the controls are focused on when the user hits tab. To set the
tab order, number the TabIndex property of the controls starting at 0
3. parameters
Parameters are the local variables used in the function definition
Parameters can be used ONLY in the function they belong to
The difference between arguments and parameters is…
Arguments are the values you pass to a function
Parameters are the local variables used in the function header
4. Name
The naming (value of the name property) of controls should indicate what it is and what it does
5. Pseudocode
Pseudocode – English-like phrases with some Visual Basic terms to outline the task
Pseudocode is good for listing the steps of an algorithm in a form that is easier to translate into VB
There is NO SPECIFIC FORM to pseudocode, it can look as much like VB or English as you want.
6. Algorithm
An Algorithm is a step-by-step procedure devised for the purpose of taking in data and producing the
correct output.
A program is the actual implementation of an algorithm in a programming language.
Before writing a program, you must develop an algorithm to solve a problem
7. Keywords
Remember the ByVal keyword in front of the parameters?
This keyword indicates that all arguments are passed to this parameter by value
Keywords are words that have a particular meaning in VB. These are reserved, meaning they can’t
be used for other purposes (this will be clearer when we talk about variables)
8.underscore character
Variable names must start with an alphabetic character or an underscore (_)
After the first character they can have any alphabetic, numeric, or underscore character
Keywords cannot be used as variable names
Const makes the constant not able to take a different value after initialization
CONSTANT_NAME As Type = value
The name of the constant should be all in caps and have underscores instead of camel case for
different words
9.Variables
A variable declared in a function or event procedure can ONLY be used in the function or event
procedure where it was declared
A variable declared inside of a class, but not in any of its procedures can be used anywhere in the
class, including in any of its procedures
If a variable or constant is declared in a procedure, its lifetimeis from the time it is declared to the
end of the procedure.
Lifetime of a variable is the period where it still resides in memory
A variable or constant (or a parameter, really) declared in a procedure is called a local variable or
local constant (local to the procedure), and is said to have local scope.
A variable not declared in a procedure, but in a class definition is said to have class-level scope
A variable declared in an if statement, select case statement, or a loop (next chapters subject) is
said to have block-level scope. Also, its lifetime is untill the block (if, select case, etc.) ends
10.logical operators
Logical Operators – combine two or more relational expressions. Return either True or False
Logical Operators – And Or Not
11.nested If blocks
Any blocks can be nested in any other blocks (If statements can be nested in for loops, etc.)
You can put if statements in other if statements. This is called nesting.
12.InputBox
InputBox(prompt, title) prompt is the message displayed inside of the dialog box, title is the text
displayed in the title of the dialog box
13.Select Case
Select Case a
Case 1
‘do something
Case 2
‘do something
Case 3
‘do something
Case Else
‘do something
End Select
14.local scope
Local scope – can be referenced anywhere in the procedure in which it was declared in
A variable or constant (or a parameter, really) declared in a procedure is called a local variable or
local constant (local to the procedure), and is said to have local scope.
15.statement Const
Sometimes you want to define a variable that will keep the same value throughout the running of the
program. These are called constants.
Const CONSTANT_NAME As Type = value
Const makes the constant not able to take a different value after initialization
The name of the constant should be all in caps and have underscores instead of camel case for
different words
You need to initialize the constant for it to have a value
16.Function names
Typically, are camel case with first letter capitalized.
Follow the same naming rules as variables
Should be a verb that describe what the function does
FunctionName is the name of the function
17.Function procedure
Functions are used in programming to break complex problems into smaller ones
The code for the function is called the function definition
When calling a function, you must supply it with the same number of arguments as parameters
defined in the function definition.
You can create functions with no parameters. Just leave the parentheses empty when defining the
function.
A function MUST return a value
You can pass input to a function by supplying it with arguments.
18.user-defined function
Function FunctionName (ByVal var1 As Type, ByValvar2 As Type) As ReturnDataType

some code

Return expression
End Function
19.Do While loop
Do While loops repeat until the condition is… False
Do Until loops repeat until the condition is… True
20.Names of arguments
You can pass input to a function by supplying it with arguments.
Arguments are the values you pass to a function
Parameters are the local variables used in the function
21.Do Loop
Do Loops execute the code they contain until a condition is false.
Do Loops come in two forms: Pretest and Posttest.

General Form of Pretest:


Do While condition
statement(s)
Pretest condition comes first

General Form of Posttest:


Do
statement(s)
Posttest checks the condition at the end.
22.counter variable
i can be any valid variable name (i is fine here though)
i is a counter variable that is incremented (one is added to it) after every iteration of the loop.

For i As numberDataType = m To n
statement(s)

23.incremented or decremented
24.For…Next loop
When we know exactly how many times a loop should be executed, a special type of loop, a
For…Next loop, can be used.

For instance…
For i As Integer = 1 To 5
MessageBox.show(i)
Next
…will show the numbers 1 through 5 in message boxes.

By default, For…Next loops increment the counter variable by 1 every iteration of the loop.
You can also define how much is added to the counter variable every iteration. This amount is
called a step value.

Here’s the basic steps when developing a Visual Basic Program:


1. Design the appearance that the user sees.
2. Determine the events that the controls on the window should respond to.
3. Write the event procedures for those events
1. In the statement: lstExample.Items.Clear(), Clear() is an example of what? A method
2. What is a step-by-step procedure devised for the purpose of taking in data and
producing the correct output? An Algorithm
3. What is NOT true about Keywords in Visual Basic? They often begin with a
lowercase letter
4. Which is NOT a step in the Program Development Cycle? Delegate responsibility
5. In the statement: lstExample.Items.Add(“Hello”), “Hello” is an example of what? A
parameter
6. When developing an algorithm, which is NOT one of the precise steps the algorithm
should follow?
A. B. C. D. E. Output solution Have events react to input
7. What is the basic form of setting a property of a control ?
controlName.property = setting
8. What is NOT true about focus in Visual Basic? Visual Basic can handle Leave
Focus events
9. What is the paradigm where the flow of a program is determined by actions such as
mouse clicks and key presses? Event-driven Programming
10. The _____ character is the symbol for the string concentration operator ampersand
11. In the statement: Dim interestRate as Double, interestRate is an example of what?
A variable name
12. The comment or ____ are used to document a program and improve its readability.
Answer
13. What kind of error would be produced by the following Visual Basic statement:
Dim interestRate as Doubl Syntax Error
14. The default data type is _______. Variant
15. What is a step-by-step procedure devised for the purpose taking in data and
producing the correct output? An algorithm
16. The ____ statement terminates program execution. End
17. What is the basic form of setting a property of a control?
controlName.property = setting
18. Write a single statement assign the product of variables area51
area51 = width22 * height88
19. The following variable declaration is correct:
Dim grades as Integers False
20. What is the paradigm where the flow of a program is determined by actions such as
mouse clicks and key presses? Even-driven Programming
21. Write a single statement to assign “Hello!” to the Label lblGreeting
lblGreeting.Caption = “Hello!”
22. What would be the result of the expression 9Mod2? 1 remainder
23. When developing an algorithm, which is NOT one of the precise steps the algorithm
should follow? Output solution
24.

You might also like