0% found this document useful (0 votes)
8 views6 pages

Tutorial

The document contains multiple choice and practical questions related to Visual Basic programming. It covers topics such as control structures, data types, events, and basic programming concepts. The questions are designed to test knowledge and understanding of Visual Basic syntax and functionality.

Uploaded by

maxprime558
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

Tutorial

The document contains multiple choice and practical questions related to Visual Basic programming. It covers topics such as control structures, data types, events, and basic programming concepts. The questions are designed to test knowledge and understanding of Visual Basic syntax and functionality.

Uploaded by

maxprime558
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Section 1: Multiple Choice Questions

Instructions: Choose the correct option (a, b, c, d). Each question carries 1 mark.

1. What does the If statement do in Visual Basic?


a. Iterates through a block of code.
b. Executes code conditionally.
c. Declares variables.
d. Outputs a message.
2. Which of the following keywords is used to terminate a loop in Visual Basic?
a. Exit
b. End
c. Stop
d. Return
3. What is the purpose of the For Each loop?
a. To iterate a fixed number of times.
b. To iterate through a collection or array.
c. To check conditions repeatedly.
d. To initialize variables.
4. Which function is used to convert a string into an integer in Visual Basic?
a. CInt()
b. ToInteger()
c. Parse()
d. ConvertString()
5. In Visual Basic, what is the default value of a Boolean variable?
a. True
b. False
c. Null
d. Undefined
6. Which event is triggered when a form is loaded?
a. Load
b. Open
c. Initialize
d. Start
7. What does the MsgBox function return?
a. A string
b. A value indicating which button was clicked
c. A boolean
d. Nothing
8. Which of the following is NOT a loop structure in Visual Basic?
a. While
b. For
c. Repeat
d. Do Until
9. Which operator is used to compare two values in Visual Basic?
a. =
b. ==
c. !=
d. <>
10. What is the output of the following code snippet?

1|2
Dim x As Integer = 10
Console.WriteLine(x \ 3)

a. 3.33
b. 3
c. 4
d. 0

11. Which property of a TextBox sets the text inside it?


a. Content
b. Caption
c. Text
d. Label
12. How do you declare a constant in Visual Basic?
a. Using Const
b. Using Dim
c. Using Static
d. Using Let
13. Which of the following is used to concatenate strings in Visual Basic?
a. +
b. &
c. *
d. $
14. What is the purpose of Option Strict?
a. To enforce explicit data type conversions.
b. To disable variable declaration.
c. To allow late binding.
d. To make variables case-sensitive.
15. What is the output of Len("Visual Basic")?
a. 12
b. 11
c. 10
d. 9
16. What is the file extension of a Visual Basic project file?
a. .exe
b. .vbproj
c. .vbscript
d. .vbs
17. Which of the following is a valid data type in Visual Basic?
a. Text
b. String
c. Character
d. Word
18. What does the MsgBox function do in Visual Basic?
a. Displays a message box.
b. Declares a variable.
c. Writes output to a file.
d. Ends a program.
19. Which keyword is used to declare a variable in Visual Basic?
a. Var

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 '

30 What is the purpose of the Sub keyword in Visual Basic?


a. To declare a function.
b. To declare a subroutine.
c. To initialize a variable.
d. To define a class.

Section 2: Practical Questions

Question 1:

Study the following program and answer the questions below:

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

a. What does the program do?


b. Explain the purpose of the following elements:

• If...Else
• Mod
• For loop

c. What will be the output of the program?

Question 2:

Write a Visual Basic program that performs the following:

1. Prompts the user to enter their name and age.


2. Checks if the user is above 18 years old.
3. If the user is 18 or older, displays a message: "Welcome, [Name]! You are eligible to
vote."

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:

1. Data types and variable declaration.


2. Events in Visual Basic and their significance.
3. Error handling in Visual Basic using Try...Catch.

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

a. What does the program do?


b. Explain the purpose of the following elements:

• 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:

1. Takes two numbers as input from the user.


2. Adds the numbers together.
3. Displays the result in a message box.

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:

1. Variables and data types.


2. Conditional statements.
3. Loops .

6|2

You might also like