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

VB Use Update

This document is a lab manual for programming with VB.NET. It contains 3 units that provide exercises to learn programming concepts and skills. The exercises include defining terms like programmer, user, coding, and programming. They also involve explaining object-oriented programming, classes, methods, and properties. Later exercises have students build applications with controls and write programs to calculate sums and costs using formulas. The overall document provides a structured set of lessons and practices to learn visual basic programming.
Copyright
© © All Rights Reserved
0% found this document useful (0 votes)
42 views

VB Use Update

This document is a lab manual for programming with VB.NET. It contains 3 units that provide exercises to learn programming concepts and skills. The exercises include defining terms like programmer, user, coding, and programming. They also involve explaining object-oriented programming, classes, methods, and properties. Later exercises have students build applications with controls and write programs to calculate sums and costs using formulas. The overall document provides a structured set of lessons and practices to learn visual basic programming.
Copyright
© © All Rights Reserved
You are on page 1/ 97

LAB MANUAL

Programming
With
VB.NET
UNIT 1

Exercise 1.0

1. What are the meanings of the terms “programmer” and “user”?


………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
2. Many programming languages, including Visual Basic, use a zero-based
numbering system. What is a zero-based numbering system?
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
3. What is the difference between coding and programming?
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………

2i
UNIT 2

Exercise 2.0

Briefly explain the following terms

1. .Net Framework Class Library:


...……………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
2. Object-oriented programming language:
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
3. Event-driven programming language:
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
4. Property:
………………………………………………………………………………………………
5. Method:
………………………………………………………………………………………………
6. Class:
………………………………………………………………………………………………

18i
Exercise 2.1

Build and test the application in this session and assign a student’s name to the Text
property of the Textbox control named NameTextBox and a student’s department to
the textbox control named MajorTextBox.

…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………
…………………………………………………………………………………………………

18ii
Exercise 2.2

a. Provide the name of the controls in the figure below.

1. A: …………………………………….

2. B: …………………………………….

3. C: …………………………………….

4. D: …………………………………….

b. State the uses of them.

A: …………………………………………………………………………………………

B: …………………………………………………………………………………………

C: …………………………………………………………………………………………

D: …………………………………………………………………………………………

18iii
UNIT 3
Exercise 3.0
Fill in the blank spaces in below in regards to Flowchart.

……………….. …………………………………………………………
…………………………………………………………

………………… …………………………………………………………
………………… …………………………………………………………

……………….. …………………………………………………………
…………………………………………………………

……………….. ………………………………………………………………
………………………………………………………………

……………….. ………………………………………………………………
………………………………………………………………

…………………………………………………………
………………..
…………………………………………………………

………………………………………………………………
………………..
………………………………………………………………

31i
Exercise 3.1
Write a program that computes the sum of two numbers and displays the result in
another textbox.

………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………

………………………………………………………………………………………………………

31ii
Exercise 3.2
The cost of the electricity used by a device is given by the formula;

Cost of electricity = wattage of device * hours used * cost per kW / 100, 000

where kWh is an abbreviation for “kilowatt hour.” The cost per kWh of electricity varies
with locality. In 2018, the average cost of electricity for a residential customer in Ghana
was 12¢ per kWh. Write a program that allows the user to calculate the cost of
operating an electrical device.

Possible Outcome

………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
……….................................................................................................................................

31iii
UNIT 4
Exercise 4.0
The flowchart below calculates a person’s income tax. Write a program corresponding
to the flowchart.

………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………

39i
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………

39ii
Exercise 4.1

Write a program that requests your date of birth as input and tells whether or not you
are 25 years old or older. If not, the program should tell you the number of days until
you will have your 25th birthday.

Possible outcome

………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………

38iii
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………

Exercise 4.2

A clothing store advertises “BUY 2 ITEMS AND THE 3 IS FREE.” What they mean is
that if you buy three items, then the lowest cost item is free. Write a program that
accepts the three costs as input and then calculates the total cost after dropping the
lowest cost.

Possible outcome

………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………

39iv
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………
………………………………………………………………………………………………………

39v
Extra Exercises
In Exercises 1 through 6 , determine the output displayed in the text box or list box by the lines of code.

1. txtBox.Text = "Visual Basic"

2. Dim var As String


var = "Bert"
txtBox.Text = var

3. Dim var As String


var = "Ernie"
lstBox.Items.Add(var)

4. lstBox.Items.Add("a" & "cute")

5. Dim s As String, n As Integer


s = "trombones"
n = 76
txtBox.Text = n & " " & s

6. Dim m As Integer = 4
Dim n As Integer = 3
Dim s As String = "Microsoft"
Dim t As String = "soft"
lstOutput.Items.Add(s.Length)
lstOutput.Items.Add(s.ToLower)
lstOutput.Items.Add(s.Substring(m, n − 1))
lstOutput.Items.Add(s.IndexOf(t))

In Exercises 7 through 11 , identify any errors.

7. Dim hiyo As String


hiyo = "Silver"
txtBox = "Hi-Yo " & hiYo

8. Dim num As Double = 1234


txtBox.Text = CStr(num.IndexOf("2"))

9. Dim num As Integer = 45


txtBox.Text = CStr(num.Length)

10. Dim m As Decimal, n As Integer


m = 2 ^ 3
n = 4 / 2

11. Dim m As Decimal, n As Integer


m =
12. PRICE OF KETCHUP The following steps compute the price of ketchup:
a. Declare the variable item as type String. Declare the
variables regularPrice and discount as type Decimal.
b. Assign “ketchup” to the variable item.
c. Assign 1.80 to the variable regularPrice.
d. Assign .27 to the variable discount.
e. Assign to the variable discountPrice the expression
(NOTE: The product is 1.53.)
f. Display the sentence “1.53 is the sale price of ketchup.”

13. DISTANCE FROM A STORM If is the number of seconds between lightning and thunder, the storm
is /5 miles away.
Write a program that reads the number of seconds between lightning and thunder and reports the
distance of the storm rounded to two decimal places.

Possible outcome of Exercise 13

You might also like