#Const Directive:It is used to define conditions.Following is a basic syntax and an example to describe #
Const Directive.
#Const constname = expression
[vbnet]<span class="com">#Const state = "WEST BENGAL"</span>[/vbnet]
[vbnet]Module Module1
#Const age = True
Sub Main()
#If age Then
Console.WriteLine("You are welcome to the Robotics Club")
#End If
Console.ReadKey()
End Sub
End Module[/vbnet]
Output:
#ExternalSource Directive:This directive will be utilized by compiler.Following is a syntax and an example.
#ExternalSource( StringLiteral , IntLiteral )
[ LogicalLine ]
#End ExternalSource
[vbnet]Module Module1
Public Class ExternalSourceTester
Sub TestExternalSource()
#ExternalSource("c:\vbprogs\directives.vb", 5)
Console.WriteLine("SPlessons brings code for you. ")
Console.WriteLine("This is External Code. ")
#End ExternalSource
End Sub
End Class
Sub Main()
Dim t As New ExternalSourceTester()
t.TestExternalSource()
Console.WriteLine("In Main.")
Console.ReadKey()
End Sub
End Module[/vbnet]
Output:
#If...#Then...#Else Directive:This directive describes conditions.Following is a syntax and
an example.
#If expression Then
statements
[ #ElseIf expression Then
[ statements ]
...
#ElseIf expression Then
[ statements ] ]
[ #Else
[ statements ] ]
#End If
[vbnet]Module Module1
#Const classCode = 8
Sub Main()
#If classCode = 7 Then
Console.WriteLine("SPlesson will bring ideas to life")
#ElseIf classCode = 8 Then
Console.WriteLine("SPlesson makes code as easy to understand")
#Else
Console.WriteLine("SPlesson tutorials will guide to bigginers and to experienced persons.")
#End If
Console.ReadKey()
End Sub
End Module[/vbnet]
Output:
#Region Directive:This directive id utilized to hide blocks of the code.Following is a syntax and an example.
#Region "identifier_string"
#End Region
[vbnet]Module Module1
#Region "INIT"
'''
<summary>
''' Initialize the program.
''' </summary>
Sub Main()
Console.WriteLine("A")
Console.WriteLine("B")
Console.WriteLine("C")
Console.WriteLine("Copyright 2013")
End Sub
#End Region
End Module[/vbnet]