Visual Basic Questions and Answers – Using the MessageBox.Show Method

This set of Visual Basic Multiple Choice Questions & Answers (MCQs) focuses on “Using the MessageBox.Show Method”.

1. An application communicates with the user through __________
a) DialogBox
b) AlertBox
c) MessageBox
d) AlertDialog
View Answer

Answer: c
Explanation: Application may need to communicate with the user during run time; one means of doing this is through a message box. You display a message box using the MessageBox.Show method. The message box contains text, one or more buttons, and an icon.

2. One can display a message box using the __________ method.
a) MessageBox
b) AlertBox.View
c) MessageBox.show
d) MessageBox.Show
View Answer

Answer: d
Explanation: Application may need to communicate with the user during run time; one means of doing this is through a message box. You display a message box using the MessageBox.Show method. The message box contains text, one or more buttons, and an icon.

3. Which is the caption part for the following Visual Basic command?

advertisement
advertisement
MessageBox.Show("Delete this record?","Payroll",MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2).

a) “Delete this record?”
b) “Payroll”
c) MessageBoxButtons.YesNo
d) MessageBoxIcon.Exclamation
View Answer

Answer: b
Explanation: The syntax of the MessageBox.Show is-

Note: Join free Sanfoundry classes at Telegram or Youtube
MessageBox.Show (text, caption, buttons, icon, [defaultButton])

The caption is given as the second component in the syntax. In the above statement, the second component is the “payroll”, thus it is the caption.

advertisement

4. When referring to the method’s return value in code, one should use the __________ value rather than the integer.
a) DoubleReturn
b) BooleanResults
c) charResult
d) DialogResult
View Answer

Answer: d
Explanation: When referring to the method’s return value in code, one should use the DialogResult value rather than an integer. The values make the code more self-documenting and easier to understand.

5. You use the __________ constant to include the Exclamation icon in a message box.
a) MessageBox.exclamation
b) MessageBox.Iconexclamation
c) MessageBoxIcon.Exclamation
d) MessageBoxWarning.Icon
View Answer

Answer: c
Explanation: The various constants like MessageBoxIcon.Exclamation is used to give icons in the Message Box. It is a constant to include the exclamation icon. MessageBoxIcon.Alert is another example which is used to give alert. MessabeBoxIcon.Close is another example, which gives the red-cross symbol.
advertisement

6. The text box’s __________ event procedure prevents user from entering a specified character.
a) KeyPress
b) check
c) checkchar
d) checkinput
View Answer

Answer: a
Explanation: The KeyPress event handles any unacceptable input the user provides in the given text area. For example, when alphabets are entered in place of numbers in text area, which is only used to enter numbers.

7. A control’s KeyPress event occurs every time __________
a) The user selects the text area
b) The user submits the information in the text area
c) The user types a character in the text area
d) The user taps the enter key
View Answer

Answer: c
Explanation: A control’s KeyPress event occurs every time the user types a character in the text area. A control’s KeyPress event occurs each time the user presses a key while the control has the focus.

8. The procedure associated with the KeyPress event has __________ parameters.
a) 2
b) 3
c) 4
d) 1
View Answer

Answer: a
Explanation: The procedure associated with the KeyPress event has two parameters, which appear within the parentheses in the procedure header, sender and e (small e).

9. ‘e’ parameter’s __________ property is used to determine the pressed key.
a) Keypress
b) KeyChar
c) Keychar
d) Key.Char
View Answer

Answer:b
Explanation: The ‘e’ parameter’s KeyChar property is used to determine the pressed key. To prevent a text box from accepting an unacceptable character, first the ‘e’ parameter’s KeyChar property is used to determine the pressed key. KeyChar stands for “key character.”

10. ‘e’ parameter’s __________ property is used to cancel the key if not accepted in the text area.
a) Remove
b) RemoveChar
c) Handled
d) handled
View Answer

Answer: c
Explanation: The ‘e’ parameter’s Handled property is used to cancel the key if it is an unacceptable one. You cancel the key by setting the ‘e’ ‘s Handled property to True, i.e. e.Handled = True.

Sanfoundry Global Education & Learning Series – Visual Basic.

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

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). 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!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.