VB Test 8 TH
VB Test 8 TH
DHA Campus
Class 8
True/False (5 Marks)
3. A variable in Visual Basic can store different types of data, such as numbers and text.
5. The For…Next loop runs an unlimited number of times until a condition is met.
7. A ______ is a block of code that performs a task and returns a value in Visual Basic.
times.
10. In Visual Studio, ______ is pressed to run the program in debug mode.
Section 3: Scenario-Based Questions (5 Marks)
11. You want to display the message "Welcome to VB!" when a button is clicked. What
code will you write inside the button click event?
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
12. A user enters two numbers in a form, and you need to add them and show the result.
What variables and data types should you use?
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
13. Your program crashes when a user enters text instead of a number in a numeric input
field. What error-handling technique can you use?
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
14. You need to create a loop that adds numbers from 1 to 100. Which type of loop will
you use and why?
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
15. You want a button to change color when the mouse pointer hovers over it. Which
mouse event will you use?
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………