Chapter 5: Programming in Visual Studio – EVALUATION SHEET
I. Tick (✔) the correct option:
-
A ______ is a value that can be recorded in the application's memory temporarily.
a. keyword
b. variable ✔
c. operand
-
Which data type is used to store either True or False value?
a. Char
b. Long
c. Boolean ✔
-
Which of the following is both an arithmetic and string operator?
a. /
b. &
c. + ✔
-
The ______ statement can be used in place of the If ... Then ... ElseIf statement?
a. For ... Next
b. Select ... Case ✔
c. While ... End
-
Which event of a RadioButton control occurs when the value of the Checked property changes?
a. CheckedChanged ✔
b. Click
c. AppearanceChanged
II. Fill in the blanks with the suitable words:
- The Val() function is used for extracting numeric value from the controls inserted in the form.
- A variable is a value that can be recorded in the application's memory temporarily.
- The property of a variable which defines its characteristics is known as Data type.
- The statement in which you declare a variable informs the compiler about the data type of the variable.
- The Do ... Loop Until statement first executes the statements and then tests the condition after each execution.
III. Write 'T' for True and 'F' for False statements:
- A variable can be longer than 255 characters. (F)
- The declaration of a variable does not store any data in it. (T)
- It is not mandatory to declare a variable in Visual Basic. (T)
- Relational operators are used to compare two different operands in a program. (T)
- For ... Next statement is used to execute a set of statements for a specific number of times. (T)
IV. Answer the following questions:
1. What is the difference between implicit and explicit declaration of a variable?
Implicit declaration: Variable is used without declaring (possible if Option Explicit
is OFF).
Explicit declaration: Variable is defined using Dim
keyword with data type.
' Explicit Declaration Dim x As Integer x = 10 ' Implicit Declaration (not recommended) y = 20
2. State the rules you should keep in mind while naming variables in a program.
- Must begin with a letter.
- Can contain letters, numbers, underscore (_).
- Cannot contain spaces or special characters.
- Should not be a reserved keyword.
- Must be meaningful.
3. Name the common data types provided in VB.
Integer, Long, Single, Double, String, Boolean, Date, Currency, Object.
Dim rollNo As Integer Dim marks As Double Dim name As String Dim isPassed As Boolean
4. Write a short note on Control Statements in Visual Basic.
Control statements manage the execution flow of a program:
- **Decision making:** If...Else, Select Case
- **Looping:** For...Next, While...End, Do...Loop
- **Jumping:** Exit, Continue
Dim i As Integer For i = 1 To 5 MsgBox("Iteration: " & i) Next i
5. What is nesting? Give the syntax of a nested If ... Then ... Else statement.
Nesting: Using one control structure inside another.
If age >= 18 Then If age >= 60 Then MsgBox("Senior Citizen") Else MsgBox("Adult") End If Else MsgBox("Minor") End If
6. Write a sample program to explain the use of string operator "&".
Dim fname As String, lname As String fname = "Pratap" lname = "Sir" MsgBox("Welcome " & fname & " " & lname) 'Output: Welcome Pratap Sir
V. Define the following terms:
- Data type: Defines the type of data a variable can store (e.g., Integer, String, Boolean).
- Operands: Values or variables on which operators perform operations.
- Inversion: Logical NOT operation (~ or Not) which reverses Boolean value.
Dim flag As Boolean flag = True MsgBox(Not flag) ' Output: False
- Relational operators: Operators used to compare two values (=, <, >, <=, >=, <>).
If 10 > 5 Then MsgBox("10 is greater") End If
- Iteration: Repeated execution of statements until condition is met (looping).
Dim i As Integer i = 1 Do While i <= 5 MsgBox("Count: " & i) i = i + 1 Loop
No comments:
Post a Comment