10
Technical-Vocational
Education (TVE)
ICT - Programming in Visual
Basic 2010
Quarter 1 – Module 7: Form
Controls, Properties and
Other Concepts
i
TVE – ICT (Programming in Visual Studio 2010) 10
Quarter 1 – Module 7: Form Controls, Properties and Other Concepts 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.
Published by the Department of Education – Schools Division Office of Makati City
OIC-Schools Division Superintendent: Carleen S. Sedilla CESE
OIC-Assistant Schools Division Superintendent: Brian E. Ilan EdD
Development Team of the Module
Writer: Arlene A. Purisima
Editor: Jean T. Tumaneng
Reviewer: Celedonia T. Teneza EdD
Layout Artist: Jean T. Tumaneng
Management Team:
Angelita S. Jalimao
Chief Education Supervisor, Curriculum Implementation Division
Neil Vincent C. Sandoval
Education Program Supervisor, LRMS
Celedonia T. Teneza EdD
Education Program Supervisor, EPP/TLE/TVL
Printed in the Philippines by the Schools Division Office of Makati City Through
the Support of the City Government of Makati (Local School Board)
Department of Education – Schools Division Office of Makati City
Office Address: Gov. Noble St., Brgy. Guadalupe Nuevo
City of Makati, Metropolitan Manila, Philippines 1212
Telefax: (632) 8882-5861 / 8882 - 5862
E-mail Address: makati.city@deped.gov.ph
ii
What I Need to Know
Hello, Grade 10 Learners! This module is designed to help you fully understand the
Form Controls, Properties and Other Concepts of Visual Basic 2010 and some
related terms. Feel free to explore each part and accomplish each activity at your own
pace.
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.
The module is divided into 2 Lesson Lesson 1 –Form, Controls and Properties
After going through this module, you are expected to:
Lesson 1 – Form controls and Properties
A. identify the controls, their names and functions;
B. recognize how to change the properties, rename, delete the controls;
Lesson2 – Basic Steps in Writing a Visual Basic Project
A. learn how to create a simple program from Visual Basic
B. describe the Timing and Modes while developing a program
What I Know
1. What object primarily represents the program interface?
a. Form Design Window c. Project Explorer Window
b. Form d. Properties Window
2. Which of the following steps in writing a Visual Basic project includes adding control so the user
can interact with the program?
a. Setup the Properties c. Design the user interface
b. Coding d. Runtime
3. Which of the following modes describes the time spent in writing and designing the codes for the
user?
a. Design time c. Break Time
b. Run time d. Debug Time
4. Which of the following buttons enlarges the current window to full screen?
a. Close button c. Minimize button
b. Maximize button d. Restore button
5. What part of the Visual Basic window contains icons that represent commonly used controls?
a. Toolbar c. Form
b. Toolbox d. Properties window
6. What do we call the VB files a programmer manipulates and deals with?
a. Command Files c. Executable Files
b. Editable Files d. Solution Files
7. Which of the following controls is used to select, move, and resize the form and other controls?
a. Pointer c. Textbox
b. Label d. Button
8. Forms, commands, buttons, labels, etc., are examples of?
a. Object c. Icon
b. Tool d. Image
9. What term is referred to as a set of rules that must be complied with, including the spelling,
symbols, and other text or words?
a. Rule c. Syntax
b. Standard d. Format
10. What files does an end user run on the computer?
a. Executable files c. Solution Files
b. Command Files d. User Files
3
Lesson Form Controls, Properties and other
1 Concepts
What’s In
Can you still recall our last meetings’ discussion? Well, let us try to identify the Parts of
the Visual Basic Environment.
The word “Visual” refers to the way the Graphical User Interface (GUI) is
designed.
4
What’s New
Activity 1: Let us Cook!
Transfer all the ingredients from the box to cook for your favorite dish adobo.
Write all the ingredients in the bowl on the right side
pork fish cheese
My Yummy Adobo!!
soy sauce pechay chicken
pineapple banana vinegar
chicken egg black pepper
Looks yummy, isn’t it? You need to complete the ingredients to prepare a delicious
meal. Every ingredient in a recipe has a specific purpose. One should know how to mix
or combine the ingredients properly. In Visual Basic, it is important to know the object or
control to enhance the appearance of your program.
What is It
Visual Basic Controls
In Visual Basic 2010, controls are useful tools that can be placed in the form to perform
various tasks. The toolbox contains the controls of VB10. Some of the most used
controls are Button, Label, Textbox, Radio button, CheckBox, ListBox and PictureBox.
Below are some common controls can be dragged or dropped to the form.
CONTROL NAME DESCRIPTION
Pointer Selects objects
Button Displays a button that the user can
click to perform an action
Check box Displays a box and a label
associated with the box
Combo box Displays a drop-down list box
DateTime Displays date and/or time
Picker information
Label Draws a box to display text
List box Displays a list of options from
which the user can select
Picture box Draws a box to display graphics
Progress Bar Displays a horizontal bar which
indicates the progress of an action
Radio Control that consists of a circle
(option) and a label associated with the
button circle
Text box Draws a box that can display text
and let the user type in text
Timer Places a timer on a form
5
Control Names
Controls have Names by default. Examples are Button1, Label1, TextBox1 and so
on. The name of the control in internal name is what the programmer uses in
referencing codes. You can change the name of the control using the following
guidelines:
1. Begin with letters (ex: name, num1, age001)
2. Use meaningful and descriptive names (ex: surname, address, sum)
3. No space allowed (ex: student1, student100)
4. No special symbols except underscore (ex: grade_1, level_2)
5. Avoid reserved words.
Changing the name of the Control
The attribute Name in the Properties Window is the default name of the control.
Note:
An object's Name property
contains the name of the
control.
The Text property is read by
the user, whereas the Name
property is used by the
programmer.
Suggested Prefixes for Controls
Control Type Prefix Example
Check box chk chkReadOnly
Combo box cbo cboEnglish
Button btn btnShow
Label lbl lblLastname
Textbox txt txtAge
Activity 2:
Write if the identifier is a valid variable and if Invalid.
1. hello 6. txt*age
2. lblname 7. employee name
3. #passGrade 8. numero_2
4. end 9. studentage
5. streetcode 10. city101
Renaming Controls
You can rename the controls by using the
commands from the Properties window.
1.Select the control, go to properties window
where the properties of the control are listed.
2.Click the alphabetical list icon on the properties
window to arrange the list of properties in
alphabetical order.
3.Go to Name attribute then change the name of
the control.
6
You try it!
Using Visual Basic 2010, generate a name on the following controls below. Use PrtScn (Print screen)
method to paste your work. No.1 is already done for you.
Control Prefix Example
1. Listbox
2. Timer
3. Picture box
4. Panel
5. Radio button
6. Label
Meaningful control names serve as a form of documentation within the code itself. They provide
hints about the purpose and usage of each control, reducing the need for external documentation and
having informative control names can help pinpoint issues more efficiently.
When an error occurs or unexpected behavior arises, you can easily identify the control
causing the problem, saving time in troubleshooting.
In summary, naming controls in Visual Basic are not just a matter of convention; it
significantly enhances code quality, understandability, maintainability, and collaboration. It is a best
practice that leads to more efficient and error-free development.
Deleting the Control
There are many ways to delete a control in the form.
1. Right click on the object and on the context menu, click Delete.
2. You can also go to the menu bar, click edit, them Delete.
3. Another way is to select the control then press Delete from the keyboard.
Lesson Basic Steps in Writing a Visual Basic
2 Project
Steps in Writing a Project
Explore the files that make up a Visual Basic project. In VB, a project is the
group of all the files that make up your program.
Design the User Interface (these include controls needed so a user can interact
with the program)
Set Up the properties for the controls e.g. names
Coding – following the syntax rules of VB, Syntax are the set of rules that
must be complied with including the spelling, punctuation marks, spacing,
symbols and other text or words.
Run the program by clicking RUN button or press F5
Debug the program – it involves identifying a problem, isolating the source of
the problem, and then either correcting the problem or determining a way to
work around it.
Modes in Visual Basic
It is the process of creating an application, designing an
Design Time
interface, setting the properties, and writing the code.
7
Run Time The time spent when the user runs an application
It is the time spent in checking, debugging, and other
Break Time situation. At this time, no changes can be made to the
program
Kinds of Visual Basic Files
1. Solution files – (.sln) these are the files that a programmer manipulate and deal
with.
2. Executable files – (.exe) a file that contains a program - that is, a kind of
file that is capable of being executed or run as a program in the computer.
Errors in Visual Basic
In any programming language, there are three common kinds of errors: syntax errors, runtime
errors, and logic errors.
1. Syntax error - are errors when the syntax of the language is not followed.
Explanation:
In this code, a syntax error occurs because
the string "Hello, world! is missing the
closing double quote. This will result in a
"Unterminated string constant" error at
compile time because VB.NET expects a
closing double quote to properly terminate
the string.
2. Runtime error - A runtime error is an application error that occurs during
program execution.
Explanation:
In this code, we're trying to divide
num1 by num2, where num2 is set to
zero. Dividing by zero is not allowed in
mathematics, and it will result in a
runtime error when you run this code.
3. Logical error - is a mistake in a program's source code that results in
incorrect or unexpected behavior
Explanation:
In this code, the programmer intended to
calculate the sum of num1 and num2, but
mistakenly used subtraction (num1 - num2)
instead of addition (num1 + num2). This
results in a logical error, where the program
runs without crashing, but it doesn't
produce the correct output. The correct line
should be sum = num1 + num2 to fix the
logical error.
Other errors:
4. Compile Errors - These errors occur during the compilation of your VB program. They prevent
your code from being successfully compiled into an executable program.
5. Type Errors - Type errors occur when you attempt to use a variable or expression of one data
type as if it were another data type.
6. Overflow Errors - An overflow error occurs when you try to assign a value to a variable that
exceeds its allowable range.
7. Null Reference Errors - These occur when you attempt to use an object reference that is set to
Nothing.
8
What’s More
Activity 1:
Directions: Using cram.com, make a flashcard about the types of errors in Visual Basic.
How to use cram: https://www.youtube.com/watch?v=Xh7xmnyKvAo
What I Have Learned
Identification
_____________ 1. What kind of control displays a button that the user can click to perform an action?
_____________ 2. What type of control displays a box and a label associated with the box?
_____________ 3. What control displays a drop-down list box in Visual Basic?
_____________ 4. In Visual Basic, where can you find the attribute used to change the name of a control?
_____________ 5. If you want to name a Button control for showing something in Visual Basic, what prefix
should you use?
True of False
_____________ 1. Informative control names can help pinpoint issues more efficiently when errors occur.
_____________ 2. Naming conventions like "chk" for Check boxes are commonly used in Visual Basic.
_____________ 3. Control names can contain spaces in Visual Basic.
_____________ 4. You can change the name of a control by clicking it twice in Visual Basic.
_____________ 5. Using special symbols in control names is a recommended practice in Visual Basic.
Short Answer
A. Discuss the benefits of using prefixes like "chk" and "cbo" for control names in Visual Basic.
Provide examples of controls that could use these prefixes.
________________________________________________________________________________________________________________
________________________________________________________________________________________________________________
________________________________________________________________________________________________________________
________________________________________________________________________________________________________________
B. Explain the difference between an executable file (.exe) and a solution file (.sln) in Visual Basic
development.
________________________________________________________________________________________________________________
________________________________________________________________________________________________________________
________________________________________________________________________________________________________________
________________________________________________________________________________________________________________
C. How can informative control names help in troubleshooting and debugging when errors occur in
a Visual Basic program?
________________________________________________________________________________________________________________
________________________________________________________________________________________________________________
________________________________________________________________________________________________________________
________________________________________________________________________________________________________________
D. Describe the three common types of errors in Visual Basic
________________________________________________________________________________________________________________
________________________________________________________________________________________________________________
________________________________________________________________________________________________________________
________________________________________________________________________________________________________________
9
What I Can Do
Design a project with the project title Student Information System. Select the
appropriate control to produce the desired output based on the title. Be creative by
using the attributes in the properties window such as back color, font, font colors, etc.
Sample Project designs:
Scoring rubrics:
• Excellent (16 points): A creative and visually appealing design with appropriate controls,
effective attribute usage, and excellent functionality and user interaction.
• Good (12-15 points): A solid design with creativity, suitable controls, decent attribute usage,
and good functionality and user interaction.
• Fair (8-11 points): A design with some creativity, suitable controls, limited attribute usage,
and fair functionality and user interaction.
• Poor (4-7 points): A design lacking creativity, control suitability, effective attribute usage,
and poor functionality and user interaction.
10
Assessment
Choose the letter of the best answer.
1. What is the primary purpose of renaming controls in Visual Basic?
a. To make the program run faster
b. To enhance code quality
c. To change the control's appearance
d. To increase the program's complexity
2. Which of the following is NOT a recommended practice when naming controls in Visual Basic?
a. Begin with letters
b. Use meaningful and descriptive names
c. Allow spaces in control names
d. Avoid reserved words
3. What attribute is used to change the name of a control in Visual Basic?
a. Text
b. Label
c. Name
d. Prefix
4. Which prefix is recommended for naming Combo Box controls?
a. chk
b. cbo
c. lbl
d. txt
5. How can you delete a control in a Visual Basic form?
a. Double-click the control
b. Press the Delete key on the keyboard
c. Right-click the control and select "Copy"
d. Go to the menu bar and click "Save"
6. What is the main benefit of using meaningful control names in Visual Basic?
a. It makes the code harder to understand
b. It reduces the need for external documentation
c. It increases program complexity
d. It improves the program's performance
7. During which mode in Visual Basic is the user interface designed by selecting control icons from
the toolbox?
a. Run Time
b. Break Time
c. Design Time
d. Debug Time
8. What is the shortcut key to run a Visual Basic program?
a. F1
b. F2
c. F4
d. F5
9. What type of error is a mistake in a program's source code that results in incorrect or unexpected
behavior?
a. Syntax error
b. Runtime error
c. Logic error
d. Program error
10. What kind of files contain the program that end users run on their computers?
a. Solution files
b. Executable files
c. Command files
d. User file
11
Additional Activities
Design a 5 item quiz type VB10 Project, you may use checkbox, and radio button for the
choices. Apply naming of controls.
For inquiries or feedback, please write or call:
Department of Education – Schools Division Office of Makati City
Gov. Noble St., Brgy. Guadalupe Nuevo
City of Makati, Metropolitan Manila, Philippines 1212
Telefax: (632) 8882-5861 / 8882-5862
Email Address: makati.city@deped.gov.ph
12