Professional Documents
Culture Documents
TVE10 Programming Q2 Weeks1to4 Binded Ver1.0
TVE10 Programming Q2 Weeks1to4 Binded Ver1.0
Technical-Vocational
Education (TVE)
COMPUTER
PROGRAMMING
Modules
Quarter 2 – Weeks 1 - 4
10
Technical Vocational
Education (TVE)
COMPUTER PROGRAMMING
Quarter 2 – Module 1
Starting a New Project
TVE 10 – ICT (Programming in Visual Studio 2010)
Alternative Delivery Mode
Quarter 2 – Module 1: Starting a New Project
First Edition, 2020
Republic Act 8293, section 176 states that: No copyright shall subsist in any work of the
Government of the Philippines. However, prior approval of the government agency or office
wherein the work is created shall be necessary for exploitation of such work for profit. Such
agency or office may, among other things, impose as a condition the payment of royalties.
Borrowed materials (i.e., songs, stories, poems, pictures, photos, brand names, trademarks, etc.)
included in this module are owned by their respective copyright holders. Every effort has been
exerted to locate and seek permission to use these materials from their respective copyright
owners. The publisher and authors do not represent nor claim ownership over them.
Management Team:
Neil Vincent C. Sandoval
Education Program Supervisor, LRMS
This module is here to guide you through this lesson. In case you were not able
to follow and understand some instances, you can always go back to that part.
What I Know
Direction: Choose the letter of the best answer. Write the chosen letter on a
separate sheet of paper.
1. Which of the following control is used to accept and display editable text?
A. Graphic C. Picture
B. Label D. Text
2. Which of the following form property is used to indicate the background color of
the form?
A. Background Color C. Form Color
B. Background Image D. Form Background Color
3. Which of the following control is used when you want to display text used for
labeling other controls and output?
A. Clock C. Textbox
B. Label D. Timer
1
4. Which of the following is the system by which the user interacts with the
computer?
A. Form C. Work Area
B. Layout D. User Interface
5. Which of the following property is used to indicate the text that will appear in
the button?
A. Caption C. Name
B. Format D. Text
Lesson
What’s In
Let us have a recap on our last module on Form Controls, Properties and
other concepts. Answer the guide questions.
1. What is a control?
2. Name at least 5 controls and give their functions.
3. How do we name controls?
What’s New
Bet you are smiling because you easily identified those sites. The picture above
are the user interface of the products or services you visited. Do you know that a
good user interface is one reason you keep coming back to the page?
2
Today, as you create your first program in Visual Basic, you will learn how to
create a user interface using Visual Basic. This will be the start of a long but fun coding
in VB. Enjoy the process!
What is It
• Text - The text, which will appear at the title bar of the form.
Things like buttons, textboxes, and labels are all things that you can add to your
Forms. They are known as controls and are kept in the Toolbox for ease of use.
3
Changing the properties
All the Visual Basic Objects can be moved, resized or customized by setting
their properties. A property is a value or characteristic held by a Visual Basic object,
such as Text or Fore Color.
You can change the properties of an object by typing or selecting the values
from the Properties window.
Lesson
Create, Run and Save the Project
2
Writing a Code:
A Visual Basic Statement has a format of: objectname. property=value
Where:
objectname- refers to the object assigned name in the project.
property- refers to the associated property to be edited or changed in an
object.
value – is the assigned value for the corresponding property.
Example:
Form1.backcolor=vbBlue
lbldisplay.text = “Hello students”
Running the Project
There are several ways to run the program:
1. Click F5 from the keyboard
Or
2. Click the click the green play button in the toolbar
Or
3. In the debug menu, click start debugging
Debugging
Debugging is the process of finding the errors in the code and removing
these errors from the code. Program errors come in three forms: syntax, logic and
runtime errors.
1. syntax errors – refers to a character or string incorrectly placed in a command or
instruction that causes a failure in execution.
4
2. logic error – are those errors that prevent your program from doing what you
expected it to do.
What’s More
Activity 2:
5
Activity 3:
From activity 2, set the properties of the form following the table below:
Direction: Identify the following terms. Write your answers on the space provided.
What I Can Do
Activity 4: Create a form that will produce the interface below. Select the appropriate
control to produce the same output/appearance. Be creative and add colors to your
form.
Criteria:
Presentation: 50%
Content: 50%
6
Sample Output:
Note: In a long bond paper, draw the user interface and create a table for
changing the properties of the objects used.
Assessment
Direction: Choose the letter of the best answer. Write the chosen letter on a
separate sheet of paper.
4. Which of the following refers to the type of user interface that uses graphics to
represent the input and output of the program?
A. IDE C. OOP
B. GUI D. RAD
5. What term refers to the assigned value for the corresponding property?
A. Information C. Object
B. Labelname D. Value
7
8. Which of the following is the system by which the user interacts with the
computer?
A. Form C. Work Area
B. Layout D. User Interface
9. What is the correct format of writing a visual basic statement?
A. Objectname.property=value C. input.process=output
B. Data.property.value D. objectname+properties=value
10. Which of the following form property is used to indicate the background color of
the form?
A. Background Color C. Form Color
B. Background Image D. Form Background Color
8
10
Technical Vocational
Education (TVE)
COMPUTER PROGRAMMING
Quarter 2 – Module 2
Variables and Data Types
TVE 10– ICT (Programming in Visual Studio 2010)
Alternative Delivery Mode
Quarter 2 – Module 2: Variables and Data Types
First Edition, 2020
Republic Act 8293, section 176 states that: No copyright shall subsist in any work of the
Government of the Philippines. However, prior approval of the government agency or office
wherein the work is created shall be necessary for exploitation of such work for profit. Such
agency or office may, among other things, impose as a condition the payment of royalties.
Borrowed materials (i.e., songs, stories, poems, pictures, photos, brand names, trademarks, etc.)
included in this module are owned by their respective copyright holders. Every effort has been
exerted to locate and seek permission to use these materials from their respective copyright
owners. The publisher and authors do not represent nor claim ownership over them.
This module is here to guide you through this lesson. In case you were not able
to follow and understand some instances, you can always go back to that part.
What I Know
Direction: Choose the letter of the best answer. Write the chosen letter on a
separate sheet of paper.
1. Which of the following is a temporary storage location for data in your program?
A. Constant
B. Memory
C. Operator
D. Variable
4. To declare a variable in Visual Basic 2010, type the variable name after the Dim
statement. What does the reserved word DIM mean?
A. Dimension
B. Diminish
C. Light color
D. Nothing, for formality sake only
1
5. Why do you need to declare variables?
A. To identify the name and the type of your variables
B. For easy retrieval of data
C. The compiler can set aside the memory needed to store the program
D. All of the above
Lesson
To transform data into information, the computer uses program. We learn from
the previous discussion that data are raw facts that are converted into a useful
information. In programming, data are associated with two different concepts: variables
and da types.
In Visual Basic 2010, it is important to note the difference among variables,
constants and the different data types, for you to be able to write the correct codes in
your program.
What’s In
Review:
1. What is a variable?
2. What are the different data types in VB 2010?
3. Give some rules in naming variables.
What’s New
ACTIVITY 1:
In this time of pandemic, you are required to give your information on a sheet of
paper for contact tracing. Please complete the form below.
2
In programming, to process the data given by the user, they are stored in a
location called variable. This topic will be discussed later.
What is It
Variable Defined
According to Halvorson, in his book entitled Visual Basic 2010, a variable is a
temporary storage location for data in your program. You can use one or many variables
in your code, and they can contain words, numbers, dates, properties, or other values.
By using variables, you can assign a short and easy-to-remember name to each
piece of data you plan to work with. Variables can hold information entered by the user
at run time, the result of a specific calculation, or a piece of data you want to display on
your form. In short, variables are handy containers that you can use to store and track
almost any type of information.
3
2. It contain a number
(ex: age123456, age_123, grade_1)
3. It must start with a lowercase letter and include a naming convention that
describes the data type
(same with examples 1 and 2)
Declaring a Variable
Before a variable can be used in the program, it must be defined first.
Variables are defined through the process of variable declaration.
Syntax:
Dim VariableName as Data Type
Where:
• Dim – means dimension, a reserved word that indicates that the line of code is a
variable declaration
• Variable Name – the name of the variable
• As Data Type – name of the data type
Examples:
Variable Explanation
Dim X as Integer Holding numeric values with a value of 0
Dim y as Integer = 20 Holding or storing a numeric value of 100
Dim remark1, remark2, Holding three empty string variables
remark3 as String
Dim remark1 = “ “ Holding an empty string
Dim remark2 = “Good day!” Holding a string value Good day!
Importance of Variables
Variables allow the program be written so that no matter what the actual data
is, the algorithm or solution still works. Rather than entering the data directly into
the program, the programmer uses variable to represent data.
What’s More
Activity 2:
Based on activity 1, name the data and assign a variable for each data. Please follow
the rules in naming a variable. Write your answer on the space provided.
Number 1 is given as an example.
4
Data Entry Assigned VariableName Example
Activity 3: Direction: Identify the following variables are valid or invalid variable
names. Write Valid if it is valid and Invalid if not.
________________ 1. 123x
________________ 2. End
________________ 3. Father’s_name
________________ 4. Last_school_attended20
________________ 5. Yearandsection
________________ 6. Average
________________ 7. Result4020
________________ 8. String
________________ 9. 143_gender
5
What I Have Learned
_____________________________________________________________________________________
2.b _______________________________________________________________________
2.c _______________________________________________________________________
2.d _______________________________________________________________________
2.e _______________________________________________________________________
3. List down the different data types in VB 2010. Give example on each.
________________________________ __________________________________
________________________________ __________________________________
________________________________ __________________________________
________________________________ __________________________________
________________________________ __________________________________
What I Can Do
Activity 4:
#1. Let your school ID scanned or photocopied and paste in a short bond paper.
Then identify those data that needs to be represented by a variable. Assign a
valid variable name on each data.
#2. Scanned/Photocopy of your registration form (last school year).
6
Note: You may use the Identification card, registration form from any member of your
family (if lost). You can also ask any member from your family for the sample electricity
or water bill.
Criteria:
Content – 50%
Presentation – 50%
Assessment
Direction: Choose the letter of the best answer. Write the chosen letter on a
separate sheet of paper.
1. What term is used to describe the type of data a variable may hold?
A. Data type C. Data Representation
B. Data Define D. Variable type
2. Which of the following shows that variable should have no special character
except underscore?
A. 123_sample C. samp1e123_
B. sample_123 D. sample$123
3. For the patient screening in the table below, what type of data represents answer
for a Yes or No questions?
A. Boolean C. Integer
B. Double D. Single
4. Which of the following is a temporary storage location for data in your program?
A. Constant C. Operator
B. Memory D. Variable
5. Visual Basic data types are divided into two categories these are __?
A. Character and String C. Label and text
B. Date and Time D. Numeric and Text
7
7. Which of the following text data is referred to as string of character?
A. some data have decimal points
B. some uses whole numbers
C. some data are used to display output
D. none of the above
10. Exam grade, your height and weight, the number of students in a class, price
of goods and monthly bills are examples of what type of data?
A. Data C. Symbolic
B. Numeric D. Text
11. To declare a variable in Visual Basic 2010, type the variable name after
the Dim statement. What does the reserved word DIM mean?
A. Dimension C. Light color
B. Diminish D. Nothing, for formality sake only
12. Which of the following data type is used for storing whole numbers?
A. Char C. Integer
B. Double D. String
14. Variable has three components: data type, name and values. Which of the
following describes the values?
A. Names, string, date C. Information stored in a variable
B. Unique name for data D. Operator used
8
10
Technical Vocational
Education (TVE)
COMPUTER PROGRAMMING
Quarter 2 – Module 3
Expression and Operators
TVE 10 – ICT (Programming in Visual Studio 2010)
Alternative Delivery Mode
Quarter 2 – Module 3: Expressions and Operators
First Edition, 2020
Republic Act 8293, section 176 states that: No copyright shall subsist in any work of the
Government of the Philippines. However, prior approval of the government agency or office
wherein the work is created shall be necessary for exploitation of such work for profit. Such
agency or office may, among other things, impose as a condition the payment of royalties.
Borrowed materials (i.e., songs, stories, poems, pictures, photos, brand names, trademarks, etc.)
included in this module are owned by their respective copyright holders. Every effort has been
exerted to locate and seek permission to use these materials from their respective copyright
owners. The publisher and authors do not represent nor claim ownership over them.
This module is here to guide you through this lesson. In case you were not able
to follow and understand some instances, you can always go back to that part.
What I Know
Direction: Choose the letter of the best answer. Write the chosen letter on a
separate sheet of paper.
1. Which of the following symbol does not represent an arithmetic operator?
A. + C. >
B. - D. /
4. Which of the following is the set of values that can be used to represent data?
A. Data type C. Operand type
B. Expression Type D. Variable types
1
Lesson
What’s In
What’s New
ACTIVITY 1:
WORD SEARCH
____________________________________________________________________________________
DIM ARITHETIC PRECEDENCE OPERATOR
VARIABLE EXPRESSION
RULES: Find and circle the words. The words are written on one straight line
from right to left, vertically, horizontally, and diagonally.
Did you find all the words? If your answer is yes, then you have a keen
eyesight! You are now ready to proceed to the discussion of our next
lesson.
2
What is It
Expression Defined
In computer programming, an expression is a combination of operands and
operators that can be evaluated to a single value. An expression must have at least
one operand but may not have any operator.
Example:
Average as double;
Average = 75.00
Another example:
price * quantity
expression
operand
operator
3
Arithmetic Operators
4
Assignment Operators
The operator that is used to assign or store a value to variable. It is one of the
most commonly used operators in many programming language.
Operator Example (x=6) Meaning
= X=6 Move the value 6 to the
variable x
+= X+=6 X=X+6
-= X-=6 X=X-6
*= X*=6 X=X*6
/= X/=6 X=X/6
\= X\=6 X=X\6
^= X^=6 X=X^6
Lesson
Assigning Values to Variable
2
In Visual basic, one needs to declare the variables before using them by assigning
names and data types. If you do so, the program will produce an error. They are
normally declared in the general section of the codes window. Use Dim keyword to
declare variable and allocate storage space for it in memory.
Syntax:
Dim x as Integer
Dim a, b, c as Integer
Dim ave as Double
Dim studname as String
lbldisplay.text=sum
txtresult.text = text1.text + text2.text
5
Example Application Using Arithmetic Operator
Steps:
1. Design the user interface
2. Set the properties of each object (from the Properties window)
Change the following:
Name
Text
Back color
Font
Font Color
3. Add the Code
Double Click the SUM Button then write the ff. code
Private sub btnsum_click()
Dim a, b, sum As Integer
a = Val(txtuna.Text)
b = Val(txtpangalawa.Text)
sum = a + b
txtsagot.text = sum
end sub
What’s More
Activity 2:
Direction: Name the following mathematical sign. Write your answers on the
space provided.
______________ 1. * ______________ 6. ( )
______________ 2. > ______________ 7. Not
______________ 3. <= ______________ 8. +
______________ 4. / ______________ 9. Mod
______________ 5. Or ______________ 10. =
Activity 3:
Direction: Solve each expression following the hierarchy of operations. Write your
step by step calculation on each line.
1. x= 4 * 10 * 10 + 6 * 10 + 14
Step 1. ___________________________________________
Step 2. ___________________________________________
Step 3. ___________________________________________
6
Step 4. ___________________________________________
Step 5. ___________________________________________
2. z= 7 * 5 + (25 * 4) + 14 * 2 Mod 4 + 10 / 2
Step 1. ___________________________________________
Step 2. ___________________________________________
Step 3. ___________________________________________
Step 4. ___________________________________________
Step 5. ___________________________________________
Step 6. ___________________________________________
Step 7. ___________________________________________
Step 8. ___________________________________________
A. Arrange each of the flowing operations according to the order that a computer
follows to solve an expression. Write your answer on the space provided. (1 to 5)
________ 1. Addition and subtraction
________ 2. Modulus Division
________ 3. Parenthesis
________ 4. Integer Division
________ 5. Exponentiation
B. TRUE or FALSE
________ 6. Double is a data type that holds whole numbers
________ 7. +, -, * and / are considered as relational operators
________ 8. Logical operator are operators that compares two or more Boolean
expression and returns a boolean value
________ 9. Order of precedence refers to the sequence in which operators are
Evaluated
________ 10. In VB, the expression Sum= num1 + num2 is same as
Sum = text1.text + text2.text
What I Can Do
Direction: Create a program that will take two numbers as input then display the
result depends on the action selected by the user.
Note: In a long bond paper, draw the user interface and create a program on each
event button.
Criteria: Presentation – 50%
Accuracy - 50%
7
Assessment
Direction: Choose the letter of the best answer. Write the chosen letter on a
separate sheet of paper.
1. What term refers to the combination of operators and operands that
evaluates to a single value?
A. Data C. Expression
B. Information D. Variable
2. Which of the following refers to a named storage that temporarily resides in the
computer memory?
A. Data C. Expression
B. Operator D. Variable
References:
https://www.programiz.com/csharp-programming/expressions-statements-blocks
https://www.computerhope.com/jargon/o/order-of-operations.htm
Visual Basic 2010 Programming, H&D Information Technology, Inc. pp 123-124.
8
10
Technical Vocational
Education (TVE)
COMPUTER PROGRAMMING
Quarter 2 – Module 4
Working with Strings
TVE 10 – ICT (Programming in Visual Studio 2010)
Alternative Delivery Mode
Quarter 2 – Module 4: Working with Strings
First Edition, 2020
Republic Act 8293, section 176 states that: No copyright shall subsist in any work of the
Government of the Philippines. However, prior approval of the government agency or office
wherein the work is created shall be necessary for exploitation of such work for profit. Such
agency or office may, among other things, impose as a condition the payment of royalties.
Borrowed materials (i.e., songs, stories, poems, pictures, photos, brand names, trademarks, etc.)
included in this module are owned by their respective copyright holders. Every effort has been
exerted to locate and seek permission to use these materials from their respective copyright
owners. The publisher and authors do not represent nor claim ownership over them.
Management Team:
Neil Vincent C. Sandoval
Education Program Supervisor, LRMS
This module is here to guide you through this lesson. In case you were not
able to follow and understand some instances, you can always go back to that part.
What I Know
Direction: Choose the letter of the best answer. Write the chosen letter on a
separate sheet of paper.
1. What is the process of combining two or more strings into one single string?
A. Addition C. Concatenation
B. Combination D. Merging
4. What command is used to extract X2 characters from the middle of the string
word, beginning with the character number x1?
A. Len C. Mid
B. LCase D. Middle
What is the output of the command: word1 & " " &word4?
A. Visual Basic is a programming language
B. Visual Basic is a third generation language
C. Visual Basic is an OOP language
D. Visual Basic is a programming language, third generation language, OOP
language
1
Lesson
Now, let's move a little bit ahead and consider a situation where we need to store
more than one character in a variable.
What’s In
Let us have a quick recap on our last module on Expressions and operators by
answering these questions.
What’s New
ACTIVITY 1: Classify the following information whether Numeric or Non-Numeric
Write a short explanation why they are classified as that.
2
What is It
STRINGS are used to represent non -numeric information such as gender, name,
address, and the like. They are always entered in code inside quotation marks.
In programming, a string is a single unit of data that made up of a series of
characters that includes letters, digits and alphanumeric symbols It is treated as the
String data type. It is non-numeric in nature, though it might consist of numbers.
Everyday life examples of strings are names, addresses, gender, cities, book titles, phone
numbers, email addresses and more. In Visual Basic 2010, you can manipulate strings
by writing code to process characters like sentences, words, text, alphanumeric
characters and more.
String CONCATENATION
In VB, you can use either the ampersand (&) or the Plus sign (+) as a
concatenation operator.
Concatenation is the process of combining two or more strings into a single string.
Word1 = “Visual”
Word2 = “Basic”
Then the string expression
Word1 & “ “ + Word2
Note: You can also add string of text to complete your message.
“ “ are used to add space.
Example: “Hello students!!” & “ “ + “ Welcome to” & “ “ + word1 & “ “ + word2
3
Example Application
CODE:
End Sub
CODE:
Lesson
2 String Function
The flexibility of using Visual Basic function in terms of manipulating string
includes searching a string, changing the case of the string, determining the reverse
of the string, position on the string…
4
Right • Right(string, Returns a string containing a specified
length) number of characters from the right side
Right(“computer”,3) of the string.
Output: ter
Mid • Mid(string, start, Used to extract X2 characters from the
length) middle of the string word, beginning with
Mid(“computer”, 4,2) the character number x.
Output: pu
InStr • InStr([start],string Returns the position of the first
, search) occurrence of one string within another.
InStr(1, “compute” ,”m”)
Output: 3
StrReverse • StrReverse(string) Returns the position of the string in the
reverse order.
StrReverse(“desserts”)
Output: stressed
LEN Ucase
1. Dim word As String Dim word As String
Dim z As Integer Dim z As String
word = "programming" word = "programming"
z = Len(word) z = UCase(word)
Label1.Text = z Label1.Text = z
LCase Left
Dim word As String Dim word As String
Dim z As String Dim z As String
word = "PROGRAmming" word = "programming"
z = LCase(word) z = Microsoft.VisualBasic.Left(word,7)
Label1.Text = z Label1.Text = z
Right Mid
Dim word As String Dim word As String
Dim z As String Dim z As String
word = "programming" word = "Programming"
z= z = Mid(word, 4, 4)
Microsoft.VisualBasic.Right(word, 4) Label1.Text = z
Label1.Text = z
Instr StrReverse
Dim z As String Dim word As String
z = InStr("The quick brown fox Dim z As String
jumps over the word = "desserts"
lazy dog", "o") z = StrReverse(word)
Label1.Text = z Label1.Text = z
5
What’s More
Do as indicated:
1. Create a new project
2. Design a user interface similar to the output below.
4. At the code editor, type the code for the event in button1.
6
After the user click the string function button, the output will be displayed in the
textbox.
Output:
B. Identification:
1. It is the process of combining two or more strings into a single string.
2. The data type used to display non-numeric values like address, name, surname…
3. This used to display the length or number of characters of the string word.
4. Used to display the Uppercase equivalent of the string.
5. Used to display the lowercase equivalent of the string.
What I Can Do
Direction: Write a program that will display the concatenated string values after
clicking the concatenate button.
User Interface:
Output:
7
Note: In a long bond paper, draw the user interface and create a program on the
concatenation button.
Criteria: Presentation – 50%
Accuracy - 50%
Assessment
Direction: Choose the letter of the best answer. Write the chosen letter on a
separate sheet of paper.
1. Which of the following used the correct syntax of right command?
A. Microsoft.Visual Basic.Right (“String Function” 7)
B. Microsoft.VisualBasic.Right (“String Function” 7)
C. Microsoft.Visual_Basic.Right (“String Function” 7)
D. None of These
2. Which of the following are used to represent non -numeric information such as
gender, name, address, and the like?
A. Boolean
B. Character
C. Expression
D. String
3. What string function returns the position of the string in the reverse order?
A. Inverse
B. Reverse
C. StrReverse
D. StringReverse
5. Which of the following is used to display the Uppercase equivalent of the string?
A. Mid
B. LCase
C. Len
D. Ucase
Reference:
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-
guide/language-features/operators-and-expressions/concatenation-operators