VB.Net is a simple, modern, object-oriented computer programming language developed by Microsoft to combine the power of .NET Framework and the common language runtime with the productivity benefits that are the hallmark of Visual Basic.
VB.NET is implemented by Microsoft's.NET framework. Therefore, it has full access to all the libraries in the .Net Framework. It's also possible to run VB.NET programs on Mono, the open-source alternative to .NET, not only under Windows but even Linux or Mac OSX.
The following reasons make VB.Net a widely used professional language:
· Modern, general purpose.
· Object oriented.
· Component oriented.
· Easy to learn.
· Structured language.
· It produces efficient programs.
· It can be compiled on a variety of computer platforms.
· Part of .Net Framework.
VB.Net Hello World Example
A VB.Net program basically consists of the following parts:
· Namespace declaration
· A class or module
· One or more procedures
· Variables
· The Main procedure
· Statements & Expressions
· Comments
Let us look at a simple code that would print the words "Hello World":
Imports System
Module Module1
'This program will display Hello World
Sub Main()
Console.WriteLine("Hello World")
Console.ReadKey()
End Sub
End Module
Basic Syntax
VB.Net is an object-oriented programming language. In Object-Oriented Programming methodology, a program consists of various objects that interact with each other by means of actions. The actions that an object may take are called methods. Objects of the same kind are said to have the same type or, more often, are said to be in the same class.
When we consider a VB.Net program, it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what do class, object, methods and instance variables mean.
When we consider a VB.Net program, it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what do class, object, methods and instance variables mean.
· Object - Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors - wagging, barking, eating, etc. An object is an instance of a class.
· Class - A class can be defined as a template/blueprint that describes the behaviors/states that objects of its type support.
· Methods - A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed.
· Instance Variables - Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables.
Data Types
Data types refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.
Variables
A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in VB.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.
Constants and Enumerations
The constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals.Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration constants as well.
The constants are treated just like regular variables except that their values cannot be modified after their definition. An enumeration is a set of named integer constants.
Modifiers
The modifiers are keywords added with any programming element to give some especial emphasis on how the programming element will behave or will be accessed in the program
For example, the access modifiers: Public, Private, Protected, Friend, Protected Friend, etc., indicate the access level of a programming element like a variable, constant, enumeration or a class.
Statements
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.
Directives
The VB.Net compiler directives give instructions to the compiler to preprocess the information before actual compilation starts.
All these directives begin with #, and only white-space characters may appear before a directive on a line. These directives are not statements.
Decision Making
Decision making structures require that the programmer specifies one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.
Loops
There may be a situation when you need to execute a block of code several numbers of times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on.
Programming languages provide various control structures that allow for more complicated execution paths. A loop statement allows us to execute a statement or group of statements multiple times and following is the general form of a loop statement in most of the programming languages
Strings
In VB.Net, you can use strings an array of characters, however, more common practice is to use the String keyword to declare a string variable. The string keyword is an alias for the System.String class.
Creating a String Object
You can create string object using one of the following methods:
· By assigning a string literal to a String variable
· By using a String class constructor
· By using the string concatenation operator (+)
· By retrieving a property or calling a method that returns a string
· By calling a formatting method to convert a value or object to its string representation
Database Access
Applications communicate with a database, firstly, to retrieve the data stored there and present it in a user-friendly way, and secondly, to update the database by inserting, modifying and deleting data.
Microsoft ActiveX Data Objects.Net (ADO.Net) is a model, a part of the .Net framework that is used by the .Net applications for retrieving, accessing and updating data.
VB.NET Excel Sheet
VB.Net provides support for interoperability between the COM object model of Microsoft Excel 2010 and your application. To avail this interoperability in your application, you need to import the namespace Microsoft.Office.Interop.Excel in your Windows Form Application.
Web Programming
A dynamic web application consists of either or both of the following two types of programs:
· Server-side scripting - these are programs executed on a web server, written using server-side scripting languages like ASP (Active Server Pages) or JSP (Java Server Pages).
· Client-side scripting - these are programs executed on the browser, written using scripting languages like JavaScript, VBScript, etc.
No comments:
Post a Comment