Including a ComboBox in an Interface - Visual Basic Questions and Answers

1.

Which property is used to specify a combo box’s style?

   A.) ComboBoxStyle
   B.) DropStyle
   C.) Style
   D.) DropDownStyle

Answer: Option 'D'

DropDownStyle

Three styles of combo boxes are available in Visual Basic. The style is controlled by the combo box’s DropDownStyle property, which can be set to Simple, DropDown (the default), or DropDownList. Each style of combo box contains a text portion and a list portion.

DigitalOcean Referral Badge

2.

The items in a combo box belong to which collection?

   A.) Items
   B.) List
   C.) ListBox
   D.) Values

Answer: Option 'A'

The items in a combo box belong to Items Collection. As you do with a list box, you use the Items collection’s Add method to add an item to a combo box.

DigitalOcean Referral Badge

3.

Which of the following selects the Cat item, which appears third in the cboAnimal control?

   A.) cboAnimal.Selected = 2
   B.) cboAnimal.Selected = “Cat”
   C.) cboAnimal.Text = “Cat”
   D.) cboAnimal.SelectedIndex=”Cat”

Answer: Option 'C'

You can use any of the following properties to select a default item, which will appear in the text portion of the combo box: SelectedIndex, SelectedItem, or Text. If no item is selected, the SelectedItem and Text properties contain the empty string, and the SelectedIndex property contains –1 (negative one). Thus cboAnimal.Text=”Cat” selects the Cat item.

DigitalOcean Referral Badge

4.

The item that appears in the text portion of a combo box is stored in which property?

   A.) SelectedText
   B.) SelectedValue
   C.) Text
   D.) TextItem

Answer: Option 'C'

You can use any of the following properties to select a default item, which will appear in the text portion of the combo box: SelectedIndex, SelectedItem, or Text. If no item is selected, the SelectedItem and Text properties contain the empty string, and the SelectedIndex property contains –1 (negative one). In the text portion, you should use the Text property; this is because the Text property contains the value either selected or entered by the user.

DigitalOcean Referral Badge

5.

A form’s _________________ event is triggered when you click the Close button on its title bar.

   A.) Close
   B.) CloseForm
   C.) FormClose
   D.) FormClosing

Answer: Option 'D'

FormClosing

To process code when a form is about to be closed, enter the code in the form’s FormClosing event procedure, which occurs when the user clicks the Close button on a form’s title bar or when the computer processes the Me.Close() statement.

DigitalOcean Referral Badge

6.

A form’s ____________ event is triggered when the computer processes the Me.Close() statement.

   A.) Close
   B.) Closing
   C.) FormClose
   D.) FormClosing

Answer: Option 'D'

To process code when a form is about to be closed enter the code in the form’s FormClosing event procedure, which occurs when the user clicks the Close button on a form’s title bar or when the computer processes the Me.Close() statement.

DigitalOcean Referral Badge

7.

Which of the following statements prevents a form from being closed?

   A.) e.Cancel = False
   B.) e.Cancel = True
   C.) sender.Close = False
   D.) e.Close = False

Answer: Option 'B'

e.Cancel = True

To prevent a form from being closed set the Cancel property of the FormClosing event procedure’s e parameter to True, i.e. set e.Cancel=True.

DigitalOcean Referral Badge

8.

Which of the following rounds the contents of the intNum variable to three decimal places?

   A.) Math.Round(3, intNum)
   B.) Math.Round(intNum, 3)
   C.) Round.Math(3, intNum)
   D.) Round.Math(intNum, 3)

Answer: Option 'B'

Math.Round(intNum, 3)

 You can use the Math.Round function to return a number rounded to a specific number of decimal places. The function’s syntax is Math.Round(value[, digits]). In the syntax, value is a numeric expression, and digits (which is optional) is an integer indicating how many places to the right of the decimal point are included in the rounding. For example, Math. Round(3.235, 2) returns the number 3.24, and Math.Round(3.234, 1) returns the number 3.2. If the digits argument is omitted, the Math.Round function returns an integer.

DigitalOcean Referral Badge

9.

A _______________ allows you to select from a list of choices.

   A.) Combo Box
   B.) Check Box
   C.) Radio Button
   D.) Combo List

Answer: Option 'A'

Combo Box

In many interfaces, combo boxes are used in place of list boxes. You use the ComboBox tool in the toolbox to add a combo box to an interface. A combo box is similar to a list box in that it allows the user to select from a list of choices. However, unlike a list box, the full list of choices in a combo box can be hidden, allowing you to save space on the form. Also unlike a list box, a combo box contains a text field. Depending on the style of the combo box, the text field may or may not be editable by the user.

DigitalOcean Referral Badge

Including a ComboBox in an Interface - Visual Basic Questions and Answers Download Pdf

Recent Posts