VB.Net Statements, Statements mean instructions which are going to give to the compiler to execute. Simply, we can also say that the statements are the combination of keywords, variables, constants and procedures.Following are the types of statements available in computer languages.
Declarative Statements
Executable Statements
Conceptual
figure
Following is a conceptual figure which shows the types of statements.
Declarative Statements
Description
The statements which are used to declare something are called as Declarative Statements.
To declare Constants, Variables and procedures.The following are the different types of declarative statements.
Module Statement
Class Statement
Structure Statement
Sub Statement
Function Statement
Declare Statement
Operator Statement
Delegate Statement
Event Statement
Property Statement
Interface Statement
Dim Statement
Dim Statement is used to declare one or more variables and also to allocate memory.
Example:
[vbnet]
Dim n as integer
Dim s as string = "Splessons"[/vbnet]
Enum Statement
Enum statement is used to declare the group of constants at a time.
Example:
[vbnet]
Enum Height
tall
medium
small
End Enum
[/vbnet]
Const Statement
Const Statement is used to declare fixed values or constant values.
Example:
[vbnet]Const Pi as double=3.14[/vbnet]
Executable Statements
Description
Executable Statements mean the statements which are going to execute and perform some actions. Executable Statements are used call procedures or loops..etc..
Example
Following is an example which describes above types of statements.
[vbnet]
Imports System
Public Class Module1
Shared Sub Main()
Dim a As Integer = 10
Dim b As Integer = 20
Console.WriteLine("a value={0}", a)
Console.WriteLine("b value={0}", b)
If (a < b) Then
Console.WriteLine("a is less than b")
Else
Console.WriteLine("a is greater than b")
End I
Console.ReadLine()
End Sub
End Class
[/vbnet]
Output:
Following output will be displayed in the console after the execution of above code.
In the above code, if condition is the executable statement.
Summary
Points
Sub statement is used to define name, arguments in the program.