SlideShare a Scribd company logo
LEARNING ACTIVITY SHEET
SPECIAL PROGRAM IN ICT 10
ADVANCED PROGRAMMING 10
First Quarter, Week 7
Name: ________________________________________ Date: _______________________________
Grade Level / Section: ___________________________
STATEMENTS: DECLARING AND EXECUTING
BACKGROUND INFORMATION FOR LEARNERS
A statement is a complete instruction in Visual Basic programs. It may contain keywords, operators, variables,
literal values, constants and expressions.
Statements could be categorized as −
• Declaration statements − these are the statements where you name a variable, constant, or procedure,
and can also specify a data type.
• Executable statements − these are the statements, which initiate actions. These statements can call a
method or function, loop or branch through blocks of code or assign values or expression to a variable or
constant. In the last case, it is called an Assignment statement.
Declaration Statements
The declaration statements are used to name and define procedures, variables, properties, arrays, and constants.
When you declare a programming element, you can also define its data type, access level, and scope.
The programming elements you may declare include variables, constants, enumerations, classes, structures,
modules, interfaces, procedures, procedure parameters, function returns, external procedure references, operators,
properties, events, and delegates.
Following are the declaration statements in VB.Net −
Sr.No Statements and Description Example
1 Dim Statement
Declares and allocates storage space for
one or more variables.
Dim number As Integer
Dim quantity As Integer = 100
Dim message As String = "Hello!"
2 Const Statement
Declares and defines one or more
constants.
Const maximum As Long = 1000
Const naturalLogBase As Object
= CDec(2.7182818284)
3 Enum Statement Enum CoffeeMugSize
Declares an enumeration and defines the
values of its members.
Jumbo
ExtraLarge
Large
Medium
Small
End Enum
4 Class Statement
Declares the name of a class and
introduces the definition of the variables,
properties, events, and procedures that the
class comprises.
Class Box
Public length As Double
Public breadth As Double
Public height As Double
End Class
5 Structure Statement
Declares the name of a structure and
introduces the definition of the variables,
properties, events, and procedures that the
structure comprises.
Structure Box
Public length As Double
Public breadth As Double
Public height As Double
End Structure
6 Module Statement
Declares the name of a module and
introduces the definition of the variables,
properties, events, and procedures that the
module comprises.
Public Module myModule
Sub Main()
Dim user As String =
InputBox("What is your name?")
MsgBox("User name is" & user)
End Sub
End Module
7 Interface Statement
Declares the name of an interface and
introduces the definitions of the members
that the interface comprises.
Public Interface MyInterface
Sub doSomething()
End Interface
8 Function Statement
Declares the name, parameters, and code
that define a Function procedure.
Function myFunction
(ByVal n As Integer) As Double
Return 5.87 * n
End Function
9 Sub Statement
Declares the name, parameters, and code
that define a Sub procedure.
Sub mySub(ByVal s As String)
Return
End Sub
10 Declare Statement
Declares a reference to a procedure
implemented in an external file.
Declare Function getUserName
Lib "advapi32.dll"
Alias "GetUserNameA"
(
ByVal lpBuffer As String,
ByRef nSize As Integer) As Integer
11 Operator Statement
Declares the operator symbol, operands,
and code that define an operator procedure
on a class or structure.
Public Shared Operator +
(ByVal x As obj, ByVal y As obj) As obj
Dim r As New obj
' implemention code for r = x + y
Return r
End Operator
12 Property Statement
Declares the name of a property, and the
property procedures used to store and
retrieve the value of the property.
ReadOnly Property quote() As String
Get
Return quoteString
End Get
End Property
13 Event Statement
Declares a user-defined event.
Public Event Finished()
14 Delegate Statement
Used to declare a delegate.
Delegate Function MathOperator(
ByVal x As Double,
ByVal y As Double
) As Double
Executable Statements
An executable statement performs an action. Statements calling a procedure, branching to another place in the
code, looping through several statements, or evaluating an expression are executable statements. An assignment
statement is a special case of an executable statement
Example
The following example demonstrates a decision making statement –
Module decisions
Sub Main()
'local variable definition '
Dim a As Integer = 10
' check the boolean condition using if statement '
If (a < 20) Then
' if condition is true then print the following '
Console.WriteLine("a is less than 20")
End If
Console.WriteLine("value of a is : {0}", a)
Console.ReadLine()
End Sub
End Module
When the above code is compiled and executed, it produces the following result –
a is less than 20;
value of a is : 10
LEARNING COMPETENCY
1. Create a program with statements.
ACTIVITIES
1. In the following programs, please indicate/write how many statements used.
Module Program
Public Class Book
Public Title As String
End Class
Sub Main()
Dim x as new Book
x.Title="VB.NET Programming"
Console.WriteLine(x.Title)
Console.ReadKey()
End Sub
End Module
Module Program
Public Class Book
Private strTitle As String
Public Property Title()
Get
Return strTitle
End Get
Set(ByVal Value)
strTitle = Value
End Set
End Property
End Class
Sub Main()
Dim x As New Book
x.Title = "Property"
Console.WriteLine(x.Title)
Console.ReadKey()
End Sub
End Module
REFLECTION
1. In your own understanding. How important is STATEMENTS in our programs?
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
____________________________________________________________________________________
REFERENCES
Electronic Resources:
https://www.tutorialspoint.com/vb.net/vb.net_statements.htm
VB.Net Programming Language Reference
www.goalkicker.com – Free Programming Books (Visual Basic .NET Notes for Professionals)
https://www.tutlane.com/tutorial/visual-basic/ - Visual Basic Tutorial
Prepared by: GENESIS P. EUGENIO
Name of Writer/s
Noted by: LABERNE A. LADIGNON, JR.
Division ICT Coordinator / OIC EPS
KEY TO CORRECTIONS
Activity 1
5
9

More Related Content

What's hot

Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in java
Ahsan Raja
 
Fnctions part2
Fnctions part2Fnctions part2
Fnctions part2
yndaravind
 
Structure In C
Structure In CStructure In C
Structure In C
yndaravind
 
Chapter13
Chapter13Chapter13
Java adapter
Java adapterJava adapter
Java adapter
Arati Gadgil
 
Refactoring Practice: Cleaner Code
Refactoring Practice: Cleaner CodeRefactoring Practice: Cleaner Code
Refactoring Practice: Cleaner Code
Chloe Choi
 
Javapolymorphism
JavapolymorphismJavapolymorphism
Javapolymorphism
karthikenlume
 
System Analysis and Design - Basic Characteristic of Object-Oriented Analysis
System Analysis and Design - Basic Characteristic of Object-Oriented AnalysisSystem Analysis and Design - Basic Characteristic of Object-Oriented Analysis
System Analysis and Design - Basic Characteristic of Object-Oriented Analysis
Dudy Ali
 
Introduction of C# & MVC
Introduction of C# & MVCIntroduction of C# & MVC
Introduction of C# & MVC
Kalpesh Satasiya
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3
Naga Muruga
 
My presentation at International Lisp Conference 2014 (ILC 2014): Hygienic Ma...
My presentation at International Lisp Conference 2014 (ILC 2014): Hygienic Ma...My presentation at International Lisp Conference 2014 (ILC 2014): Hygienic Ma...
My presentation at International Lisp Conference 2014 (ILC 2014): Hygienic Ma...
Tokyo Tech (Tokyo Institute of Technology)
 
Interface in java
Interface in javaInterface in java
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
Elizabeth alexander
 
Strategy Design Pattern
Strategy Design PatternStrategy Design Pattern
Strategy Design Pattern
Ganesh Kolhe
 
Inheritance in Java
Inheritance in JavaInheritance in Java
Inheritance in Java
Tamanna Akter
 
Interface in java ,multiple inheritance in java, interface implementation
Interface in java ,multiple inheritance in java, interface implementationInterface in java ,multiple inheritance in java, interface implementation
Interface in java ,multiple inheritance in java, interface implementation
HoneyChintal
 
E3
E3E3
E3
lksoo
 
Inheritance and Polymorphism Java
Inheritance and Polymorphism JavaInheritance and Polymorphism Java
Inheritance and Polymorphism Java
M. Raihan
 
Common table expressions
Common table expressionsCommon table expressions
Common table expressions
Anne Lee
 
Polymorphism in java, method overloading and method overriding
Polymorphism in java,  method overloading and method overridingPolymorphism in java,  method overloading and method overriding
Polymorphism in java, method overloading and method overriding
JavaTportal
 

What's hot (20)

Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in java
 
Fnctions part2
Fnctions part2Fnctions part2
Fnctions part2
 
Structure In C
Structure In CStructure In C
Structure In C
 
Chapter13
Chapter13Chapter13
Chapter13
 
Java adapter
Java adapterJava adapter
Java adapter
 
Refactoring Practice: Cleaner Code
Refactoring Practice: Cleaner CodeRefactoring Practice: Cleaner Code
Refactoring Practice: Cleaner Code
 
Javapolymorphism
JavapolymorphismJavapolymorphism
Javapolymorphism
 
System Analysis and Design - Basic Characteristic of Object-Oriented Analysis
System Analysis and Design - Basic Characteristic of Object-Oriented AnalysisSystem Analysis and Design - Basic Characteristic of Object-Oriented Analysis
System Analysis and Design - Basic Characteristic of Object-Oriented Analysis
 
Introduction of C# & MVC
Introduction of C# & MVCIntroduction of C# & MVC
Introduction of C# & MVC
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3
 
My presentation at International Lisp Conference 2014 (ILC 2014): Hygienic Ma...
My presentation at International Lisp Conference 2014 (ILC 2014): Hygienic Ma...My presentation at International Lisp Conference 2014 (ILC 2014): Hygienic Ma...
My presentation at International Lisp Conference 2014 (ILC 2014): Hygienic Ma...
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Strategy Design Pattern
Strategy Design PatternStrategy Design Pattern
Strategy Design Pattern
 
Inheritance in Java
Inheritance in JavaInheritance in Java
Inheritance in Java
 
Interface in java ,multiple inheritance in java, interface implementation
Interface in java ,multiple inheritance in java, interface implementationInterface in java ,multiple inheritance in java, interface implementation
Interface in java ,multiple inheritance in java, interface implementation
 
E3
E3E3
E3
 
Inheritance and Polymorphism Java
Inheritance and Polymorphism JavaInheritance and Polymorphism Java
Inheritance and Polymorphism Java
 
Common table expressions
Common table expressionsCommon table expressions
Common table expressions
 
Polymorphism in java, method overloading and method overriding
Polymorphism in java,  method overloading and method overridingPolymorphism in java,  method overloading and method overriding
Polymorphism in java, method overloading and method overriding
 

Similar to 10 ap week 7 vbnet statements-genesis eugenio

AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1
guest38bf
 
Contact management system
Contact management systemContact management system
Contact management system
SHARDA SHARAN
 
Book management system
Book management systemBook management system
Book management system
SHARDA SHARAN
 
Library management system
Library management systemLibrary management system
Library management system
SHARDA SHARAN
 
Basic construction of c
Basic construction of cBasic construction of c
Basic construction of c
kinish kumar
 
Vb introduction.
Vb introduction.Vb introduction.
Vb introduction.
sagaroceanic11
 
Introduction to Visual Basic
Introduction to Visual Basic Introduction to Visual Basic
ASP.Net Technologies Part-2
ASP.Net Technologies Part-2ASP.Net Technologies Part-2
ASP.Net Technologies Part-2
Vasudev Sharma
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
NicheTech Com. Solutions Pvt. Ltd.
 
Ms vb
Ms vbMs vb
Ms vb
sirjade4
 
Password protected diary
Password protected diaryPassword protected diary
Password protected diary
SHARDA SHARAN
 
Oopp Lab Work
Oopp Lab WorkOopp Lab Work
Oopp Lab Work
Heather Dionne
 
Functions
FunctionsFunctions
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
Durgesh Singh
 
How much do we know about Object-Oriented Programming?
How much do we know about Object-Oriented Programming?How much do we know about Object-Oriented Programming?
How much do we know about Object-Oriented Programming?
Sandro Mancuso
 
Mastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsMastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_arguments
Ruth Marvin
 
Csharp
CsharpCsharp
Csharp
vinayabburi
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 intro
JOSEPHINEA6
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
Saurav Kumar
 
Unit 1
Unit  1Unit  1
Unit 1
donny101
 

Similar to 10 ap week 7 vbnet statements-genesis eugenio (20)

AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1
 
Contact management system
Contact management systemContact management system
Contact management system
 
Book management system
Book management systemBook management system
Book management system
 
Library management system
Library management systemLibrary management system
Library management system
 
Basic construction of c
Basic construction of cBasic construction of c
Basic construction of c
 
Vb introduction.
Vb introduction.Vb introduction.
Vb introduction.
 
Introduction to Visual Basic
Introduction to Visual Basic Introduction to Visual Basic
Introduction to Visual Basic
 
ASP.Net Technologies Part-2
ASP.Net Technologies Part-2ASP.Net Technologies Part-2
ASP.Net Technologies Part-2
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
 
Ms vb
Ms vbMs vb
Ms vb
 
Password protected diary
Password protected diaryPassword protected diary
Password protected diary
 
Oopp Lab Work
Oopp Lab WorkOopp Lab Work
Oopp Lab Work
 
Functions
FunctionsFunctions
Functions
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
 
How much do we know about Object-Oriented Programming?
How much do we know about Object-Oriented Programming?How much do we know about Object-Oriented Programming?
How much do we know about Object-Oriented Programming?
 
Mastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_argumentsMastering Python lesson 4_functions_parameters_arguments
Mastering Python lesson 4_functions_parameters_arguments
 
Csharp
CsharpCsharp
Csharp
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 intro
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
 
Unit 1
Unit  1Unit  1
Unit 1
 

Recently uploaded

原版制作(Hull毕业证书)赫尔大学毕业证Offer一模一样
原版制作(Hull毕业证书)赫尔大学毕业证Offer一模一样原版制作(Hull毕业证书)赫尔大学毕业证Offer一模一样
原版制作(Hull毕业证书)赫尔大学毕业证Offer一模一样
7lkkjxt
 
ChatGPT 4o for social media step by step Guide.pdf
ChatGPT 4o for social media step by step Guide.pdfChatGPT 4o for social media step by step Guide.pdf
ChatGPT 4o for social media step by step Guide.pdf
almutabbil
 
一比一原版(AU毕业证)英国阿伯丁大学毕业证如何办理
一比一原版(AU毕业证)英国阿伯丁大学毕业证如何办理一比一原版(AU毕业证)英国阿伯丁大学毕业证如何办理
一比一原版(AU毕业证)英国阿伯丁大学毕业证如何办理
anubug
 
SOCIAL MEDIA MARKETING agency and service
SOCIAL MEDIA MARKETING agency and serviceSOCIAL MEDIA MARKETING agency and service
SOCIAL MEDIA MARKETING agency and service
viralbusinessmarketi
 
CYBER SECURITY ENHANCEMENT IN NIGERIA. A CASE STUDY OF SIX STATES IN THE NORT...
CYBER SECURITY ENHANCEMENT IN NIGERIA. A CASE STUDY OF SIX STATES IN THE NORT...CYBER SECURITY ENHANCEMENT IN NIGERIA. A CASE STUDY OF SIX STATES IN THE NORT...
CYBER SECURITY ENHANCEMENT IN NIGERIA. A CASE STUDY OF SIX STATES IN THE NORT...
AJHSSR Journal
 
快速办理(worcester毕业证书)伍斯特大学毕业证PDF成绩单一模一样
快速办理(worcester毕业证书)伍斯特大学毕业证PDF成绩单一模一样快速办理(worcester毕业证书)伍斯特大学毕业证PDF成绩单一模一样
快速办理(worcester毕业证书)伍斯特大学毕业证PDF成绩单一模一样
9u4xjk4w
 
UR BHATTI ACADEMY AND ONLINE COURSES.pdf
UR BHATTI ACADEMY AND ONLINE COURSES.pdfUR BHATTI ACADEMY AND ONLINE COURSES.pdf
UR BHATTI ACADEMY AND ONLINE COURSES.pdf
urbhattiacademy
 
一比一原版(UCSD毕业证)加利福尼亚大学圣迭戈分校毕业证如何办理
一比一原版(UCSD毕业证)加利福尼亚大学圣迭戈分校毕业证如何办理一比一原版(UCSD毕业证)加利福尼亚大学圣迭戈分校毕业证如何办理
一比一原版(UCSD毕业证)加利福尼亚大学圣迭戈分校毕业证如何办理
wozek1
 
一比一原版(CSULB毕业证)加州州立大学长滩分校毕业证如何办理
一比一原版(CSULB毕业证)加州州立大学长滩分校毕业证如何办理一比一原版(CSULB毕业证)加州州立大学长滩分校毕业证如何办理
一比一原版(CSULB毕业证)加州州立大学长滩分校毕业证如何办理
exqfuhe
 
Using Playlists to Increase YouTube Watch Time
Using Playlists to Increase YouTube Watch TimeUsing Playlists to Increase YouTube Watch Time
Using Playlists to Increase YouTube Watch Time
SocioCosmos
 
Top Google Tools for SEO: Enhance Your Website's Performance
Top Google Tools for SEO: Enhance Your Website's PerformanceTop Google Tools for SEO: Enhance Your Website's Performance
Top Google Tools for SEO: Enhance Your Website's Performance
Elysian Digital Services Pvt. Ltd.
 
On Storytelling & Magic Realism in Rushdie’s Midnight’s Children, Shame, and ...
On Storytelling & Magic Realism in Rushdie’s Midnight’s Children, Shame, and ...On Storytelling & Magic Realism in Rushdie’s Midnight’s Children, Shame, and ...
On Storytelling & Magic Realism in Rushdie’s Midnight’s Children, Shame, and ...
AJHSSR Journal
 
Maximize Your Twitch Potential!..........
Maximize Your Twitch Potential!..........Maximize Your Twitch Potential!..........
Maximize Your Twitch Potential!..........
SocioCosmos
 

Recently uploaded (13)

原版制作(Hull毕业证书)赫尔大学毕业证Offer一模一样
原版制作(Hull毕业证书)赫尔大学毕业证Offer一模一样原版制作(Hull毕业证书)赫尔大学毕业证Offer一模一样
原版制作(Hull毕业证书)赫尔大学毕业证Offer一模一样
 
ChatGPT 4o for social media step by step Guide.pdf
ChatGPT 4o for social media step by step Guide.pdfChatGPT 4o for social media step by step Guide.pdf
ChatGPT 4o for social media step by step Guide.pdf
 
一比一原版(AU毕业证)英国阿伯丁大学毕业证如何办理
一比一原版(AU毕业证)英国阿伯丁大学毕业证如何办理一比一原版(AU毕业证)英国阿伯丁大学毕业证如何办理
一比一原版(AU毕业证)英国阿伯丁大学毕业证如何办理
 
SOCIAL MEDIA MARKETING agency and service
SOCIAL MEDIA MARKETING agency and serviceSOCIAL MEDIA MARKETING agency and service
SOCIAL MEDIA MARKETING agency and service
 
CYBER SECURITY ENHANCEMENT IN NIGERIA. A CASE STUDY OF SIX STATES IN THE NORT...
CYBER SECURITY ENHANCEMENT IN NIGERIA. A CASE STUDY OF SIX STATES IN THE NORT...CYBER SECURITY ENHANCEMENT IN NIGERIA. A CASE STUDY OF SIX STATES IN THE NORT...
CYBER SECURITY ENHANCEMENT IN NIGERIA. A CASE STUDY OF SIX STATES IN THE NORT...
 
快速办理(worcester毕业证书)伍斯特大学毕业证PDF成绩单一模一样
快速办理(worcester毕业证书)伍斯特大学毕业证PDF成绩单一模一样快速办理(worcester毕业证书)伍斯特大学毕业证PDF成绩单一模一样
快速办理(worcester毕业证书)伍斯特大学毕业证PDF成绩单一模一样
 
UR BHATTI ACADEMY AND ONLINE COURSES.pdf
UR BHATTI ACADEMY AND ONLINE COURSES.pdfUR BHATTI ACADEMY AND ONLINE COURSES.pdf
UR BHATTI ACADEMY AND ONLINE COURSES.pdf
 
一比一原版(UCSD毕业证)加利福尼亚大学圣迭戈分校毕业证如何办理
一比一原版(UCSD毕业证)加利福尼亚大学圣迭戈分校毕业证如何办理一比一原版(UCSD毕业证)加利福尼亚大学圣迭戈分校毕业证如何办理
一比一原版(UCSD毕业证)加利福尼亚大学圣迭戈分校毕业证如何办理
 
一比一原版(CSULB毕业证)加州州立大学长滩分校毕业证如何办理
一比一原版(CSULB毕业证)加州州立大学长滩分校毕业证如何办理一比一原版(CSULB毕业证)加州州立大学长滩分校毕业证如何办理
一比一原版(CSULB毕业证)加州州立大学长滩分校毕业证如何办理
 
Using Playlists to Increase YouTube Watch Time
Using Playlists to Increase YouTube Watch TimeUsing Playlists to Increase YouTube Watch Time
Using Playlists to Increase YouTube Watch Time
 
Top Google Tools for SEO: Enhance Your Website's Performance
Top Google Tools for SEO: Enhance Your Website's PerformanceTop Google Tools for SEO: Enhance Your Website's Performance
Top Google Tools for SEO: Enhance Your Website's Performance
 
On Storytelling & Magic Realism in Rushdie’s Midnight’s Children, Shame, and ...
On Storytelling & Magic Realism in Rushdie’s Midnight’s Children, Shame, and ...On Storytelling & Magic Realism in Rushdie’s Midnight’s Children, Shame, and ...
On Storytelling & Magic Realism in Rushdie’s Midnight’s Children, Shame, and ...
 
Maximize Your Twitch Potential!..........
Maximize Your Twitch Potential!..........Maximize Your Twitch Potential!..........
Maximize Your Twitch Potential!..........
 

10 ap week 7 vbnet statements-genesis eugenio

  • 1. LEARNING ACTIVITY SHEET SPECIAL PROGRAM IN ICT 10 ADVANCED PROGRAMMING 10 First Quarter, Week 7 Name: ________________________________________ Date: _______________________________ Grade Level / Section: ___________________________ STATEMENTS: DECLARING AND EXECUTING BACKGROUND INFORMATION FOR LEARNERS A statement is a complete instruction in Visual Basic programs. It may contain keywords, operators, variables, literal values, constants and expressions. Statements could be categorized as − • Declaration statements − these are the statements where you name a variable, constant, or procedure, and can also specify a data type. • Executable statements − these are the statements, which initiate actions. These statements can call a method or function, loop or branch through blocks of code or assign values or expression to a variable or constant. In the last case, it is called an Assignment statement. Declaration Statements The declaration statements are used to name and define procedures, variables, properties, arrays, and constants. When you declare a programming element, you can also define its data type, access level, and scope. The programming elements you may declare include variables, constants, enumerations, classes, structures, modules, interfaces, procedures, procedure parameters, function returns, external procedure references, operators, properties, events, and delegates. Following are the declaration statements in VB.Net − Sr.No Statements and Description Example 1 Dim Statement Declares and allocates storage space for one or more variables. Dim number As Integer Dim quantity As Integer = 100 Dim message As String = "Hello!" 2 Const Statement Declares and defines one or more constants. Const maximum As Long = 1000 Const naturalLogBase As Object = CDec(2.7182818284) 3 Enum Statement Enum CoffeeMugSize
  • 2. Declares an enumeration and defines the values of its members. Jumbo ExtraLarge Large Medium Small End Enum 4 Class Statement Declares the name of a class and introduces the definition of the variables, properties, events, and procedures that the class comprises. Class Box Public length As Double Public breadth As Double Public height As Double End Class 5 Structure Statement Declares the name of a structure and introduces the definition of the variables, properties, events, and procedures that the structure comprises. Structure Box Public length As Double Public breadth As Double Public height As Double End Structure 6 Module Statement Declares the name of a module and introduces the definition of the variables, properties, events, and procedures that the module comprises. Public Module myModule Sub Main() Dim user As String = InputBox("What is your name?") MsgBox("User name is" & user) End Sub End Module 7 Interface Statement Declares the name of an interface and introduces the definitions of the members that the interface comprises. Public Interface MyInterface Sub doSomething() End Interface 8 Function Statement Declares the name, parameters, and code that define a Function procedure. Function myFunction (ByVal n As Integer) As Double Return 5.87 * n End Function 9 Sub Statement Declares the name, parameters, and code that define a Sub procedure. Sub mySub(ByVal s As String) Return End Sub
  • 3. 10 Declare Statement Declares a reference to a procedure implemented in an external file. Declare Function getUserName Lib "advapi32.dll" Alias "GetUserNameA" ( ByVal lpBuffer As String, ByRef nSize As Integer) As Integer 11 Operator Statement Declares the operator symbol, operands, and code that define an operator procedure on a class or structure. Public Shared Operator + (ByVal x As obj, ByVal y As obj) As obj Dim r As New obj ' implemention code for r = x + y Return r End Operator 12 Property Statement Declares the name of a property, and the property procedures used to store and retrieve the value of the property. ReadOnly Property quote() As String Get Return quoteString End Get End Property 13 Event Statement Declares a user-defined event. Public Event Finished() 14 Delegate Statement Used to declare a delegate. Delegate Function MathOperator( ByVal x As Double, ByVal y As Double ) As Double Executable Statements An executable statement performs an action. Statements calling a procedure, branching to another place in the code, looping through several statements, or evaluating an expression are executable statements. An assignment statement is a special case of an executable statement Example The following example demonstrates a decision making statement – Module decisions Sub Main() 'local variable definition ' Dim a As Integer = 10
  • 4. ' check the boolean condition using if statement ' If (a < 20) Then ' if condition is true then print the following ' Console.WriteLine("a is less than 20") End If Console.WriteLine("value of a is : {0}", a) Console.ReadLine() End Sub End Module When the above code is compiled and executed, it produces the following result – a is less than 20; value of a is : 10 LEARNING COMPETENCY 1. Create a program with statements. ACTIVITIES 1. In the following programs, please indicate/write how many statements used. Module Program Public Class Book Public Title As String End Class Sub Main() Dim x as new Book x.Title="VB.NET Programming" Console.WriteLine(x.Title) Console.ReadKey() End Sub End Module Module Program Public Class Book Private strTitle As String Public Property Title() Get Return strTitle End Get Set(ByVal Value) strTitle = Value End Set End Property
  • 5. End Class Sub Main() Dim x As New Book x.Title = "Property" Console.WriteLine(x.Title) Console.ReadKey() End Sub End Module REFLECTION 1. In your own understanding. How important is STATEMENTS in our programs? ____________________________________________________________________________________ ____________________________________________________________________________________ ____________________________________________________________________________________ ____________________________________________________________________________________ REFERENCES Electronic Resources: https://www.tutorialspoint.com/vb.net/vb.net_statements.htm VB.Net Programming Language Reference www.goalkicker.com – Free Programming Books (Visual Basic .NET Notes for Professionals) https://www.tutlane.com/tutorial/visual-basic/ - Visual Basic Tutorial Prepared by: GENESIS P. EUGENIO Name of Writer/s Noted by: LABERNE A. LADIGNON, JR. Division ICT Coordinator / OIC EPS KEY TO CORRECTIONS Activity 1 5 9