CPT 186 - Visual Basic

138 terms by sromer

Create a new folder

Advertisement Upgrade to remove ads

All test questions

Syntax error

A project that halts during execution due to a misspelled name of an object or property, was halted due to a(n) _______.

Object oriented programming language

Visual Basic.NET is a(n) _______.

Graphical User Interface

Microsoft Windows uses a GUI environment. GUI (pronounced "gooey") stands for _______.

Design time

While you are creating the user interface you are in _______.

Me.Close

The code that is used in a sub procedure to stop execution of a program is _______.

Logic error

If a project runs, but the results are not correct, this is called a(n) _______.

Change the text in the NameTextBox control to the color red

The code: NameTextBox.ForeColor = Color.Red, will _______.

Text box

You are designing a form and it will be necessary for the user to type in their name. You should use a _____________ for inputting the user's name.

Checked

If a radio button is currently selected, its _______ property will be True.

All of the above are objects

Which of the following is not an object?

Set the Visible property to False

If you want to make a PictureBox disappear from the form when the project runs, you must _______.

MessageLabel.Text = MessageLabel.Text & " " & NameTextBox.Text

Which of the following is a valid example of concatenation?

Text

The property used to display information in a TextBox is _______.

Module-level variable

A variable that is declared in the Declarations section of a form is a(n) _______.

Private

What statement should be used to declare a module-level variable?

The format specifier codes

In order to control the number of decimals that will appear when a number is displayed, you can use _______.

14

What will be the value of AnswerInteger after execution of these statements?
Const NUMBER_A_Integer as Integer = 6
Const NUMBER_B_Integer as Integer = 4
Const NUMBER_C_Integer as Integer = 2
AnswerInteger = NUMBER_A_Integer + NUMBER_B_Integer * NUMBER_C_Integer

Real

Which of the following is not a valid data type?

TotalSalesDecimal.ToString("P2")

Which of the following is the correct code that will display the value in TotalSalesDecimal with a percent sign and 2 decimals?

Exponentiation

Which of the following has the highest order of precedence in arithmetic expressions?

True

Remark statements are not executable code.

True

The Visual Studio IDE will automatically create a new folder for each new project.

True

After you have added a label to a form you can change the words that are displayed inside the label by changing the Text property.

False

If the programmer does not write code for a button control, Visual Basic automatically provides code in the Click procedure that will close the form when the user clicks the button.

False

In Form1.Text, the word Text is referring to a method.

False

Setting the Cancel property of a button to True will allow the user to press Enter to select the button.

True

The statement: ItemTextBox.Focus(), will place the insertion point in the text box called ItemTextBox.

False

Your project requires the user to choose their gender. You should display the choices, Male and Female, using check boxes.

False

Labels are used primarily for user input.

True

Joining two strings of text is called concatenation.

False

The text property of a label or text box control can be cleared by using the Delete method.

False

If you would like to change the font property of five controls on your form so that they are all the same, you cannot change them as a group, you must change them individually.

False

A variable that will store totals and that will be available to all procedures in the form must be declared as a constant.

True

SCHOOL_NAME_String is in the correct format for a constant that holds the name of your school.

True

A numeric variable that is declared with the Dim statement in a local procedure is initialized to zero each time the procedure occurs.

True

A variable must be declared with a Dim, Private or Public statement before it is used if Option Strict is turned on.

True

Data whose value may not be changed during the execution of a project is referred to as a constant.

True

When using the format specifier codes, you can specify the number of digits to appear to the right of the decimal point.

True

Message boxes can contain buttons.

AmountTextBox.Text = AmountDecimal.ToString("C")

Write the VB code that will place the contents of the variable AmountDecimal into the text box called AmountTextBox and display the value in a currency format.

Dim ValueDecimal As Decimal

Write the statement to declare a variable called Value that will hold a number that contains a fractional amount. Be sure to add the correct suffix at the end of the variable name.

MessageLabel.Visible = True

Write a statement to make the radio button called BlackRadioButton appear selected.

PrintCheckBox.Checked = False

Write the code to make the check box called PrintCheckBox appear unchecked.

MessageLabel.ForeColor = Color.Red

Write the statement to change the color of the text in label MessageLabel to Red.

Try
PriceDecimal = Decimal.Parse(PriceTextBox.Text)
Catch PriceException As FormatException
MessageLabel.Text("Error in input data.")
End Try

Write the statement(s) to convert the value in the text box, PriceTextBox, to decimal and store the result in the variable PriceDecimal which has already been created (you don't have to write the Dim statement). Add a Try/Catch block so that when an error results during the conversion, display the error message "Error in input data" in the label MessageLabel.

MessageBox.Show("Quantity should be numeric and greater than 0!", "Error", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

Write the statement(s) to display a Message Box on the screen with the message "Quantity should be numeric and greater than 0!". The Message Box should use "Error" in the title bar and should use the OK button and the Exclamation icon.

Visual Basic is fun

What will display in MessageLabel when the following statements are executed? Assume that CountInteger=10.
MessageString = "Visual Basic is fun"
IF CountInteger <= 10 Then
MessageLabel.Text = MessageString.ToLower
ELSEIF CountInteger > 20 Then
MessageLabel.Text = MessageString.ToUpper
ELSE
MessageLabel.Text = MessageString
END IF

VISUAL BASIC IS FUN!

______________ will be the result of: MessageText .Text = MessageText .Text.ToUpper when the value of MessageText .Text is "Visual Basic is fun!".

If

Which of the following is not a logical operator?

It must begin with Select Case and it must end with End Case

Which of the following statements does not apply to the Case structure?

Both answers b and c are correct

Nested Ifs are allowed, _______.

Call

You can write a set of instructions in an event and then ________ the event from any other procedure.

12

What is the value of MysteryInteger when the following statements are executed?
Const NUMBER_Integer As Integer = 10
Select Case NUMBER_Integer
Case 1, 3, 5, 7, 9
MysteryInteger = NUMBER_Integer
Case 2, 4, 6, 8, 10
MysteryInteger = NUMBER_Integer + 1 * 2
Case Else
MysteryInteger = NUMBER_Integer * 2 + 1
End Select

Case Else

_______ is an optional clause available for the Case Structure when no match is found in any of the Case statements.

And

With the logical operator _______ , both conditions must be true for the entire condition to evaluate True.

The Autos Window

You can use _______________ as your project executes in order to view the values of variables and control contents that are referenced in the current statement and a few statements on either side of the current statement.

Edit

Which of the following is not a type of common dialog box?

The text property of a menu item can only be changed in the Menu Designer

Which of the following is not true about using keyboard access with a menu item?

EmployeeLabel.Font = FontDialog1.Font

Which of the following is the correct way to assign a font to a label using common dialog boxes after the statement FontDialog1.ShowDialog() has been executed?

You can add a separator between menu items by using the Line control from the toolbox

Which of the following statements about context menus is not true?

It is shown in gray

Which of the following is NOT true about a menu item that has a check mark?

A sub procedure returns a value to the point from which it was called

Which of the following statements is NOT true?

An argument that is passed ByRef cannot alter the original value

Which of the following is NOT true about passing arguments to procedures or functions?

Context menu

If you right-click an object, what type of menu pops-up?

Text

What property in a menu item's property window is used to change the words that will display in the menu?

True

In an If...Then...Else statement, the Else clause is optional.

True

The code: If NumAInteger <> NumBInteger Then, evaluates True when NumAInteger=3 and NumBInteger=5.

False

A block of If...Then...Else must begin with an If statement and end with an EndOfIf statement.

True

A line of code which is marked as a breakpoint will have a large red dot in the left margin and the code will be highlighted in red.

True

Or and And are logical operators used in compound conditions.

False

The Uniform Modeling Language(UML) can be used to nest if statements in code.

True

It's a good idea to always use the ToUpper or ToLower method on the Text property of text boxes, whenever comparing string values.

True

The TestChecked CheckBox may be tested to determine if it is checked by using the following code:
If TestChecked.Checked Then

True

While a program is running, you can stop at a particular location by inserting a breakpoint in the code.

True

The AND operator requires that both conditions be True for the compound condition to be True.

True

If you want the user to be able to use the dialog boxes from the Windows environment so they can save files and change colors, you will need to add two common dialog components to your form, the SaveFileDialog for saving files, and the ColorDialog for changing colors.

True

You can pass arguments to sub procedures and function procedures.

True

General procedures: sub procedures and function procedures, can be supplied with values, called arguments.

True

When an argument is sent ByVal, a copy of the argument's value is sent to the procedure so that the procedure cannot alter the original value.

False

After placing a common dialog control on the form, you can display the dialog box at run time using the OpenDialog method.

True

It is possible to create procedures that are not associated with click events.

False

When creating menus with the MenuStrip component, the Name property is used to hold the words that will appear on the screen in the menu bar.

True

The return value from a function procedure is contained in a variable with the same name as the function.

True

By default, all new menu items have their Enabled property set to True.

False

If you click on an item in a menu that is grayed out, you will toggle it on, and it will appear in black text.

DisplayLogoToolStripMenuItem.Enabled = False

Write the code to make the menu selection called DisplayLogoToolStripMenuItem appear grayed out so that it is unavailable.

Try
InputInteger = Integer.Parse(InputTextBox.Text)
Catch
MessageBox.Show("Input not numeric")
End Try

Create a set of statements that will validate that the text box object InputTextBox is a numeric value and set the variable InputInteger to the integer value of the InputTextBox object using the Integer.Parse. If the value is not numeric and an exception occurs then display a message box saying "Input not numeric". Use Try/Catch to validate.

If LanguageTextBox.Text.ToLower() = "visual basic" Then
MessageBox.Show("You are programming in Visual Basic!")
End If

Write the statement(s) that will take the value a user has typed into the text box called LanguageTextBox, convert it to lowercase and then test to see if it is equal to the string "visual basic". If the strings match display a message box saying "You are programming in Visual Basic!".

Public Sub ColorToolStripMenuItem_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles _
ColorToolStripMenuItem.Click
'Change MessageLabel text color

With ColorDialog1
.Color = MessageLabel.ForeColor
.ShowDialog()
MessageLabel.ForeColor = .Color
End With

End Sub

Write the code for the ColorToolStripMenuItem menu selection that will allow the user to change the color of the MessageLabel text to the color selected by the user from the ColorDialog1 Color dialog box when the menu selection is clicked. Below you will be given the first and last lines of the procedure and you are to write the rest.

Public Sub ColorToolStripMenuItem_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles_
ColorToolStripMenuItem.Click
'Change MessageLabel text color

'Your code goes here

End Sub

Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click

With FontDialog1
.Font = NameTextBox.Font
.ShowDialog()
NameTextBox.Font = .Font
End With
End Sub

Write the code for the FontToolStripMenuItem menu selection that will allow the user to change the font properties of the NameTextBox text to the font properties selected by the user from the FontDialog1 Font dialog box when the menu selection is clicked. Below you will be given the first and last lines of the procedure and you are to write the rest. Be sure to include the Private Sub event header and the End Sub at the end.

Close

If you need to have a form disappear and you want it removed from memory you should use the _______ method.

Add Existing Item

To add a form from another project into your project, select _______ from the "Project" menu.

Startup form

When a project begins the first form to display after the Splash Screen if there is one is called the _______.

Close method

If you have many forms in your project and you are sure you won't need a form again, it is best to use the _______ when making the form disappear.

Private

Variables declared as _______ are available only to the one form.

Both answers A and C would remove a form from a project.

You can remove a form from a project by _______.

4

How many times will the statements inside this For/Next loop be executed?
For IndexInteger = 2 to 12 Step 3
'Statements in loop
Next IndexInteger

will make the program difficult to read and understand

Incorrect indentation of the statements in For/Next loops _______.

setting the Sorted property to True

Items in a list can be placed in alphabetical order by _______.

ColorListBox.Items.RemoveAt (ColorListBox.SelectedIndex)

The code to delete the selected item from ColorListBox is _______.

hold a list of values

List boxes and combo boxes _______.

Answers A and B are correct

The data that appears in a combo box when it is first displayed can be added to the combo box _______.

TextChanged event

Which text box event occurs each time the user types a character into a text box?

the user should be notified if there is no match found in the table

When performing a table lookup, it is a good idea to include validation because _______.

an element

An array is a set of variables. Each individual variable is called _______.

For Each / Next statement

When you are working with an array, the easiest way to traverse the elements without using a subscript is to use the _______.

TotalSalesDecimal(1) += SalesDecimal

Which of the following code samples is valid for accumulating the total sales for the Tigers baseball club if the Tigers are the second group in the list?

Sean

What is the value of NameString(1,1) after the following declaration is initialized?
Dim NameString ( , ) As String = {{ "James", "Mary"},{ "Sammie", "Sean"}}

A table lookup

__________ can be used to find a specific value in an array.

26

How many elements are contained in the array created with the following code?
Dim EmployeeString(25) As String

True

In order to make a splash screen appear when a project begins, you must designate the form that is the splash screen in the Project Designer.

True

About boxes are typically displayed by selecting "About" from the "Help" menu.

False

The form's Load event occurs each time the form is displayed.

True

Add a new form to a project by selecting "Add Windows Form" from the "Project" menu.

True

Using a static local variable is better than using a module-level variable because it is always best to keep the scope of a variable as narrow as possible.

False

If a variable is declared with a Dim statement in a sub procedure, all other forms in the project will have access to that variable.

True

The programmer can change the program's version by modifying the Assembly Information.

True

If you want to remove an item from a list during run time, you can use either the Items.RemoveAt method or the Items.Remove method.

False

The counter in a For/Next loop can be a variable or a constant.

True

The Continue statement can be used to skip to the next iteration of a loop.

True

List boxes have a Text property but it can only be accessed at run time.

True

The code, "NameLabel.Text = NameComboBox.Text", or the code, "NameLabel.Text = NameComboBox.Items(NameComboBox.SelectedIndex)" will display the selected name in NameLabel.

True

Boolean variables are commonly referred to as switches or flags.

True

The SelectedIndex property can be used to select an item in the list or to determine which item is selected.

False

When an array is initialized with the Dim Statement, the index starts at 1 instead of 0.

True

An array is a list or series of values.

False

The following code is valid for declaring an array with ten elements: Dim employeeNameString(0 to 10).

True

An exception is automatically thrown if a subscript is used that is not a valid element in an array.

True

A table lookup is used to find a match for a specific value (or string) by comparing it to each element in an array.

True

The SelectedIndex property of a list box can be used as an array subscript to find an item in a list box.

MajorTextBox.SelectAll()

Write the statement(s) to make the entry in the text box called MajorTextBox appear selected when the text box's Enter event procedure occurs. The first and last lines of the procedure are given. You just need to write the single statement that will be placed inside the procedure.

ShirtsForm.Close()

Write a statement to close the form called ShirtsForm.

MainForm.Close()

Write the statement to make the form named, MainForm,
disappear and be removed from memory.

Dim AmountDecimal(14) As Decimal

Write a statement to create a one-dimensional decimal array called
AmountDecimal that will contain 15 elements.

MessageBox.Show("The number of flavors in the list is " & FlavorsComboBox.Items.Count)

Write the statement to display the message "The number of flavors in the list is " followed by the number of items in the combo box called FlavorsComboBox in a message box.

For CountInteger = 50 to 0 Step ‐5
'statements in loop
Next CountInteger

Write the first and last lines of a For/Next that will start
the value of the LoopIndex variable called
CountInteger at 50 and will count down by 5's until
the value in CountInteger is less than 0.

For RowInteger as Integer = 0 to 5
For ColInteger as Integer = 0 to 5
AmountDecimal(RowInteger, ColInteger) = 0.0D
Next ColInteger
Next RowInteger

Given the declaration for the following 2 dimensional array, write the statements to initialize the elements of the AmountDecimal array to 0.0D. Assume that the array has already been loaded with decimal values and your code will be used to reinitialize the array back to 0. Include the Dim statements for any additional variables that you might need.

For IndexInteger = 0 to 5
CountInteger(IndexInteger) += 5
Next IndexInteger

Given the following variable declarations, write a For/Next loop to add 5 to each element of the CountInteger array. Assume that the array has already been loaded with integer values and your code will increment each array element by 5.

Please allow access to your computer’s microphone to use Voice Recording.

Having trouble? Click here for help.

We can’t access your microphone!

Click the icon above to update your browser permissions above and try again

Example:

Reload the page to try again!

Reload

Press Cmd-0 to reset your zoom

Press Ctrl-0 to reset your zoom

It looks like your browser might be zoomed in or out. Your browser needs to be zoomed to a normal size to record audio.

Please upgrade Flash or install Chrome
to use Voice Recording.

For more help, see our troubleshooting page.

Your microphone is muted

For help fixing this issue, see this FAQ.

Star this term

You can study starred terms together

NEW! Voice Recording

Create Set