0% found this document useful (0 votes)
2 views

visual basic 1

The document provides a comprehensive overview of Visual Basic programming concepts, including properties of forms, menu editor functionality, and distinctions between methods and functions. It outlines the steps for creating applications, types of constants, and differences between TextBox and MaskedTextBox. Additionally, it discusses IntelliSense, printing options, flow control constructs, and debugging facilities, along with code examples and advantages of sub-procedures.

Uploaded by

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

visual basic 1

The document provides a comprehensive overview of Visual Basic programming concepts, including properties of forms, menu editor functionality, and distinctions between methods and functions. It outlines the steps for creating applications, types of constants, and differences between TextBox and MaskedTextBox. Additionally, it discusses IntelliSense, printing options, flow control constructs, and debugging facilities, along with code examples and advantages of sub-procedures.

Uploaded by

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

Here’s a detailed breakdown of answers for all questions in the document, organized by marks.

SECTION A - COMPULSORY (30 Marks)

QUESTION 1

(a) Describe the three most common properties of forms in Visual Basic. (6 Marks)

1. Name: Identifies the form; used in code to reference it. Default is Form1.

2. Text: The title displayed in the form's title bar. Can be modified in the properties window.

3. BackColor: Sets the background color of the form. Helps improve user interface aesthetics.

(b) Describe the menu editor as used in Visual Basic programming. (2 Marks)
The menu editor is a tool in Visual Basic used to create and manage menu systems for applications. It
allows developers to define menu items, assign shortcuts, and set properties like enabling/disabling
specific options.

(c) Distinguish between a method and a function as used in Visual Basic. (4 Marks)

 Method: Performs an action on an object, e.g., Show() to display a form.

 Function: Returns a value after performing operations, e.g., Len() returns the length of a
string.

(d) Describe the three steps used when creating an application using VB. (6 Marks)

1. Design: Add and arrange forms, controls, and user interface elements.

2. Code: Write event-driven code to define application behavior.

3. Test/Debug: Run the program, fix errors, and ensure functionality aligns with requirements.

(e) Describe the two types of constants in Visual Basic with examples. (4 Marks)

1. Intrinsic Constants: Predefined constants in VB, e.g., vbYes, vbOKCancel.

2. User-defined Constants: Declared by programmers using Const. Example:

3. Const Pi As Double = 3.14159

(f) Describe the quickest way to reset the VB IDE layout. (4 Marks)
The quickest way is to go to the menu Tools > Import and Export Settings and choose "Reset All
Settings." Select the default environment layout and confirm.

(g) Differentiate between a TextBox and a MaskedTextBox. (4 Marks)

 TextBox: Accepts unrestricted input from the user, e.g., any text or numbers.

 MaskedTextBox: Restricts input based on a predefined format, e.g., phone numbers (###-
###-####).

SECTION B (Choose Any Two Questions) (20 Marks Each)


QUESTION 2

(a) Describe VB's IntelliSense feature and explain how it is accessed. (5 Marks)
IntelliSense is an auto-completion feature in Visual Basic that provides suggestions, parameter lists,
and documentation as you type. It’s accessed while coding by typing a dot (.) after an object or
pressing Ctrl + Space.

(b) Discuss the printing PrintAction options in VB.Net. (6 Marks)

1. PrintToFile: Sends output to a file instead of a printer.

2. PrintToPrinter: Sends output to the default printer.

3. PrintToPreview: Displays a print preview window before printing.

(c) Outline three disadvantages of using visual programming languages. (3 Marks)

1. May have a steep learning curve for beginners.

2. Slower performance compared to lower-level languages.

3. Limited flexibility for complex tasks.

(d) Define the following terms and provide examples: (6 Marks)


i. Variable: A named storage for data. Example:

Dim age As Integer = 25

ii. Constant: A fixed value that doesn’t change. Example:

Const TaxRate As Double = 0.16

iii. Array: A collection of items of the same type. Example:

Dim scores(4) As Integer = {10, 20, 30, 40, 50}

QUESTION 3

(a) List 3 objects and 3 events used in VB with functions. (6 Marks)

 Objects:

1. Button: Triggers events like Click.

2. TextBox: Accepts user input.

3. Label: Displays text.

 Events:

1. Click: Triggered when a button is clicked.

2. TextChanged: Triggered when text in a TextBox changes.

3. MouseHover: Triggered when the mouse hovers over a control.

(b) Describe four flow control constructs in VB. (4 Marks)


1. If...Else: Executes code conditionally.

2. Select Case: Executes code based on multiple conditions.

3. For...Next: Executes a block of code a fixed number of times.

4. Do...Loop: Executes a block repeatedly while a condition is true.

(c) Difference between design-time and run-time modes. (4 Marks)

 Design-Time: Used for creating and modifying application layout and properties.

 Run-Time: Application executes, allowing user interaction and dynamic behavior.

(d) Explain the following events with use cases. (6 Marks)

1. Form Load: Occurs when a form loads. Use: Initialize variables.

2. KeyPress: Triggered when a key is pressed. Use: Validate input.

3. QueryUnload: Fires before closing the form. Use: Confirm exit.

QUESTION 4

(a) Discuss properties, methods, and events of an object using a balloon example. (6 Marks)

 Properties: Attributes of the balloon, e.g., color, size.

 Methods: Actions, e.g., inflate, deflate.

 Events: Triggers, e.g., balloon pops when overinflated.

(b) Write code for the following tasks: (10 Marks)

1. optMale.Checked = True

2.

3. lblTest.Text = "This is Visual Basic"

4.

5. MessageBox.Show("My Name is John")

6.

7. cboTest.Items.Add("Programming")

8.

9. txtCourses.Focus()

10.

(c) Discuss two debugging facilities in VB. (4 Marks)

1. Breakpoints: Halt execution to inspect variables.

2. Immediate Window: Execute and test code snippets during debugging.


QUESTION 5

(a) Write a program to calculate the sum of two numbers and display the result. (8 Marks)

Public Class Form1

Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click

Dim num1 As Integer = CInt(txtNum1.Text)

Dim num2 As Integer = CInt(txtNum2.Text)

Dim sum As Integer = CalculateSum(num1, num2)

lblResult.Text = "Sum: " & sum

End Sub

Private Function CalculateSum(a As Integer, b As Integer) As Integer

Return a + b

End Function

End Class

(b) Three advantages of sub-procedures/functions. (6 Marks)

1. Code reuse and modularity.

2. Easier debugging and testing.

3. Improved readability and maintenance.

(c) Three ways to declare variables in VB. (6 Marks)

1. Explicit:

2. Dim x As Integer = 10

3. With Type Inference:

4. Dim x = 10

5. Static Variables:

6. Static counter As Integer = 0

Let me know if you need further clarification!

You might also like