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
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
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?
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
Explanation: The syntax of the MessageBox.Show is-
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.
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
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
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.
6. The text box’s __________ event procedure prevents user from entering a specified character.
a) KeyPress
b) check
c) checkchar
d) checkinput
View Answer
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
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
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
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
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.
- Practice Computer Science MCQs
- Apply for Visual Basic Internship
- Buy Computer Science Books
- Apply for Computer Science Internship
- Buy Visual Basic Books