Declaration Statements: SR - No Statements and Description Example
Declaration Statements: SR - No Statements and Description Example
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 −
3 Enum CoffeeMugSize
Enum Statement
Jumbo
Declares an enumeration ExtraLarge
and defines the values of Large
its members. Medium
Small
End Enum
4 Class Box
Class Statement
Public length As Double
Public breadth As Double
Declares the name of a Public height As Double
class and introduces the End Class
definition of the variables,
properties, events, and
procedures that the class
comprises.
5 Structure Box
Structure Statement
Public length As Double
Declares the name of a Public breadth As Double
structure and introduces Public height As Double
the definition of the End Structure
variables, properties,
events, and procedures
that the structure
comprises.
8 Function myFunction
Function Statement
(ByVal n As Integer) As Double
Declares the name, Return 5.87 * n
parameters, and code End Function
that define a Function
procedure.
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 −
Live Demo
Module decisions
Sub Main()
'local variable definition '
Dim a As Integer = 10
When the above code is compiled and executed, it produces the following result −
a is less than 20;
value of a is : 10