Visual Basic Questions and Answers – Repetition Structure – Refresh and Sleep Methods, Including List Box in an Interface

This set of Visual Basic Interview Questions and Answers for Experienced people focuses on “Repetition Structure – Refresh and Sleep Methods, Including List Box in an Interface”.

1. The _________________ ensures that the computer processes any previous lines of code that affect the interface’s appearance.
a) Refresh Method
b) Sleep method
c) Count method
d) Accumulator method
View Answer

Answer: a
Explanation: The Refresh method ensures that the computer processes any previous lines of code that affect the interface’s appearance. The Refresh method’s syntax is Me.Refresh(), in which Me refers to the current form.

2. To delay program execution, you can use the _____________________
a) Refresh Method
b) Sleep method
c) Count method
d) Accumulator method
View Answer

Answer: b
Explanation: To delay program execution, you can use the Sleep method in the following syntax: System.Threading.Thread.Sleep(milliseconds). The milliseconds argument is the number of milliseconds to suspend the program.

3. A millisecond is ____________ of a second.
a) 1/1000
b) 1/100
c) 1/10
d) 1/10000
View Answer

Answer: a
Explanation: A millisecond is 1/1000 of a second; in other words, there are 1000 milliseconds in a second. A millisecond is smaller unit than second.

4. Which of the following statements pauses program execution for 1 second?
a) System.Threading.Thread.Pause(1000)
b) System.Threading.Thread.Pause(1)
c) System.Threading.Thread.Sleep(1000)
d) System.Threading.Thread.Sleep(100)
View Answer

Answer: c
Explanation: To delay program execution, you can use the Sleep method in the following syntax: System.Threading.Thread.Sleep(milliseconds). The milliseconds argument is the number of milliseconds to suspend the program. A millisecond is 1/1000 of a second; in other words, there are 1000 milliseconds in a second. A millisecond is smaller unit than second.
advertisement
advertisement

5. What will the following code display in the lblSum control?

Dim intSum As Integer
Dim intY As Integer
Do While intY < 3
For intX As Integer = 1 To 4
intSum = intSum + intX
Next intX
intY = intY + 1
Loop
lblSum.Text = Convert.ToString(intSum)

a) 5
b) 8
c) 15
d) 30
View Answer

Answer: d
Explanation: The inner for loop calculates intSum as 10, and is processed thrice due to the outer for loop, thus the value of intSum at the end of both the loops is 30.
advertisement

6. What will the following code display in the lblAsterisks control?

For intX As Integer = 1 To 2
For intY As Integer = 1 To 3
lblAsterisks.Text = lblAsterisks.Text & "*"
Next intY
lblAsterisks.Text = lblAsterisks.Text &
ControlChars.NewLine
Next intX

a)

***
***
advertisement

b)

***
***
***

c)

***

d)

***
***
***
***
View Answer
Answer: a
Explanation: The inner loop prints * thrice since intY runs from 1 to 3 and the outer loop processes the inner loop twice since intX runs from 1 to 2. Thus * is printed in two rows.
 
 

7. A _______________displays a list of choices.
a) List box
b) Display box
c) Choice box
d) Check box
View Answer

Answer: a
Explanation: A list box displays a list of choices from which the user can select zero choices,
one choice, or multiple choices. A list box is a graphical control element that allows the user to select one or more items from a list contained within a static, multiple line text box.

8. The number of choices the user can select is controlled by the list box’s ________________
a) SelectionModeProperty
b) Select Property
c) Check Property
d) IsSelect Property
View Answer

Answer: a
Explanation: The number of choices the user can select is controlled by the list box’s SelectionMode property. The default value for the property is One, which allows the user to select only one choice at a time. You can make a list box any size you want. However, the Windows standard for list boxes is to display a minimum of three choices and a maximum of eight choices at a time. If you have more items than can fit into the list box, the control automatically displays a scroll bar for viewing the complete list of items.

9. The items in a list box belong to a collection called the ______________
a) Collection
b) Items Collection
c) Items Add
d) Add
View Answer

Answer: b
Explanation: The items in a list box belong to a collection called the Items collection. A collection is a group of individual objects treated as one unit. The first item in the Items collection appears as the first item in the list box. The second item in the collection appears as the second item in the list box, and so on.

10. You specify each item to display in a list box using the Items collection’s______________
a) Add method
b) Subtract method
c) Divide method
d) Multiply method
View Answer

Answer: a
Explanation: A unique number called an index identifies each item in the Items collection. The first item in the collection (which also is the first item in the list box) has an index of 0. The second item has an index of 1, and so on. You specify each item to display in a list box using the Items collection’s Add method.

Sanfoundry Global Education & Learning Series – Visual Basic.

To practice all areas of Visual Basic for Interviews, 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.