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

«
»

This set of Visual Basic Quiz focuses on “Including a ComboBox in an Interface”.

1. Which property is used to specify a combo box’s style?
a) ComboBoxStyle
b) DropDownStyle
c) DropStyle
d) Style
View Answer

Answer: b
Explanation: 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.
advertisement

2. The items in a combo box belong to which collection?
a) Items
b) List
c) ListBox
d) Values
View Answer

Answer: a
Explanation: 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.

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”
View Answer

Answer: c
Explanation: 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.

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
View Answer

Answer: c
Explanation: 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.

5. The _______________ event occurs when the user either types a value in the text portion of a combo box or selects a different item in the list portion.
a) ChangedItem
b) ChangedValue
c) SelectedItemChanged
d) TextChanged
View Answer

Answer: d
Explanation: 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. When the value in the text portion of a combo box changes, the combo box’s TextChanged event occurs.
advertisement

6. A form’s _________________ event is triggered when you click the Close button on its title bar.
a) Close
b) CloseForm
c) FormClose
d) FormClosing
View Answer

Answer: d
Explanation: 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.

7. A form’s ____________ event is triggered when the computer processes the Me.Close() statement.
a) Close
b) Closing
c) FormClose
d) FormClosing
View Answer

Answer: d
Explanation: 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.

8. Which of the following statements prevents a form from being closed?
a) e.Cancel = False
b) e.Cancel = True
c) e.Close = False
d) sender.Close = False
View Answer

Answer: b
Explanation: 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.

9. 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(intNum, 3)
d) Round.Math(3, intNum)
View Answer

Answer: b
Explanation: 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.
advertisement

10. A _______________ allows you to select from a list of choices.
a) Combo Box
b) Combo List
c) Check Box
d) Radio Button
View Answer

Answer: a
Explanation: 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.

Sanfoundry Global Education & Learning Series – Visual Basic.

To practice all areas of Visual Basic for Quizzes, here is complete set of 1000+ Multiple Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn