Tutorial
Tutorial
Instructions: Choose the correct option (a, b, c, d). Each question carries 1 mark.
1|2
Dim x As Integer = 10
Console.WriteLine(x \ 3)
a. 3.33
b. 3
c. 4
d. 0
2|2
b. Dim
c. Declare
d. Const
20. What is the purpose of the Do While loop?
a. To execute a block of code a fixed number of times.
b. To execute code as long as a condition is true.
c. To check for errors in the program.
d. To terminate the program.
21. In Visual Basic, which control is used to display a list of items?
a. TextBox
b. ComboBox
c. Button
d. PictureBox
22. What is the default value of an integer variable in Visual Basic?
a. Null
b. 0
c. 1
d. Undefined
23. Which event is triggered when a button is clicked?
a. Click
b. Load
c. Hover
d. Press
24. What does Option Explicit enforce in Visual Basic?
a. Variable declaration before use.
b. Compilation optimization.
c. Error handling.
d. Case sensitivity.
25. How do you concatenate strings in Visual Basic?
a. Using +
b. Using &
c. Using *
d. Using #
26. What is the output of MsgBox("Welcome")?
a. Displays "Welcome" in a message box.
b. Writes "Welcome" to a file.
c. Exits the program.
d. Saves "Welcome" to a variable.
27. Which property is used to set the text of a TextBox?
a. Caption
b. Value
c. Text
d. Label
28. What does the If statement do in Visual Basic?
a. Executes code conditionally.
b. Iterates through a block of code.
c. Declares variables.
d. Opens a file.
29. How do you create a comment in Visual Basic?
a. Using //
3|2
b. Using /* */
c. Using #
d. Using '
Question 1:
Module Program
Sub Main()
Dim num As Integer = 15
If num Mod 2 = 0 Then
Console.WriteLine("The number is even.")
Else
Console.WriteLine("The number is odd.")
End If
For i As Integer = 1 To 5
Console.WriteLine("Square of " & i & " is " & (i * i))
Next
End Sub
End Module
• If...Else
• Mod
• For loop
Question 2:
4|2
4. Otherwise, displays a message: "Sorry, [Name]. You are not eligible to vote."
Question 3:
Explain the importance of loops in Visual Basic. Discuss the differences between For, While,
and Do Until loops with examples.
Question 4:
Write short notes on the following Visual Basic concepts, providing examples for each:
Question 5:
Study the following Visual Basic program and answer the questions below:
Module Program
Sub Main()
Dim num1 As Integer = 5
Dim num2 As Integer = 10
Dim result As Integer
result = num1 + num2
Console.WriteLine("The sum is: " & result)
Console.ReadLine()
End Sub
End Module
• Dim
• Console.WriteLine
• &
• Console.ReadLine
c. What will be the output of the program?
Question 6:
Write a Visual Basic program that performs the following:
5|2
Question 7:
Explain the importance of using events in Visual Basic. Provide two examples of events and
their use cases.
Question 8:
Discuss the following Visual Basic concepts with examples:
6|2