Net compiler directives give instructions to the compiler to preprocess the information before actual compilation starts. Net compiler does not have a separate preprocessor; however, the directives are processed as if there was one. Net, the compiler directives are used to help in conditional compilation.
All these directives begin with #, and only white-space characters may appear before a directive on a line. Unlike C and C directives, they are not used to create macros. Net provides the following set of compiler directives: This directive is used for indicating a mapping between specific lines of source code and text external to the source.
It also affects how Visual Basic searches the external file for the external procedure name.
Net program structure so that we can take it as a reference in upcoming chapters. Net program basically consists of the following parts: VB. In Object-Oriented Programming methodology, a program consists of various objects that interact with each other by means of actions. An object is an instance of a class: A class may have members that can be accessible from outside class, if so specified. The Dim statement is used at module, class, structure, procedure or block level. Net is: Dim Student ID As Integer Dim Student Name As String Dim Salary As Double Dim count1, count2 As Integer Dim status As Boolean Dim exit Button As New System. The Const statement is used at module, class, structure, procedure, or block level for use in place of literal values.
Therefore before discussing the available tools for running a VB. Mono can be run on many operating systems including Android, BSD, i OS, Linux, OS X, Windows, Solaris and UNIX. Net programming language, let us look a bare minimum VB. Read Key() End Sub End Module A variable is nothing but a name given to a storage area that our programs can manipulate. Net has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable. The Dim statement is used for variable declaration and storage allocation for one or more variables. Button Dim last Time, next Time As Date Module variables Ndataypes Sub Main() Dim message As String Console. An enumeration is a set of named integer constants. Net, constants are declared using the Const statement.
Net basic syntax on the basis of our observations in it: Imports System Public Class Rectangle Private length As Double Private width As Double 'Public methods Public Sub Accept Details() length = 4.5 width = 3.5 End Sub Public Function Get Area() As Double Get Area = length * width End Function Public Sub Display() Console. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted. Read Key() End Sub End Module Module Data Types Sub Main() Dim n As Integer Dim da As Date Dim bl As Boolean = True n = 1234567 da = Today Console. The syntax for the Enum statement is as follows: Module constants Nenum Enum Colors red = 1 orange = 2 yellow = 3 green = 4 azure = 5 blue = 6 violet = 7 End Enum Sub Main() Console.
Therefore, it has full access to all the libraries in the . NET, not only under Windows, but even Linux or Mac OSX. Net a widely used professional language: In this chapter, we will discuss the tools available for creating VB. Let us now briefly look into what do class, object, methods and instant variables mean. Let us look at an implementation of a Rectangle class and discuss VB. Write Line("Area: ", Get Area()) End Sub Shared Sub Main() Dim r As New Rectangle() r. Instance methods are invoked through an object of the class: Data types refer to an extensive system used for declaring variables or functions of different types. The following table shows all the data types available: Module Data Types Sub Main() Dim b As Byte Dim n As Integer Dim si As Single Dim d As Double Dim da As Date Dim c As Char Dim s As String Dim bl As Boolean b = 1 n = 1234567 si = 0.12345678901234566 d = 0.12345678901234566 da = Today c = "U"c s = "Me" If Script Engine = "VB" Then bl = True Else bl = False End If If bl Then 'the oath taking Console. Write Line("declaring on the day of: ", da) Console. Write Line("The Single: , The Double: ", si, d) End If Console. The Enum statement can be used at the module, class, structure, procedure, or block level.
It is used only by the compiler and the debugger has no effect on code compilation.