VB.Net - SPLessons

VB.Net Basic Syntax

Home > Lesson > Chapter 6
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

VB.Net Basic Syntax

VB.Net Basic Syntax

shape Description

VB.Net is an Object Oriented Programming Language which only deals with Objects. All the objects interact with other objects by means of actions. Here, Actions means Methods. VB.Net is a collection of the objects which is used to perform some action through methods.Likewise, in the other languages Dot Net will also have the native features , class and objects have the same functionality in every language.Following is the conceptual figure which describes what are the elements are placed in object oriented programming language.

shape Conceptual figure

shape Elements

The following are the different Elements in an Object Oriented Programming Language.
  • Object - An Object is an instance of the Class. Object have the States and Behaviour. Example: Pen is an object. Pen have the color and brand which means states. The Pen is used for writing which means behaviour.
  • Class - As a practical definition class can be defined as a box inside of this box user can write methods and functions.Class may have more objects but object will have only one class.
  • Methods - Method is used to perform some action. Inside of this methods developer can write logic to the code.
  • Variables - A variable is used to store the data. Example:  int a; Here, a is the variable.

shape Examples

Let us take an Example for the object called Square. Here, the variable is side and method is the area used to perform some action which means method. [vbnet]Imports System Public Class Square Private side As Double Public Sub GetSide() side = 4 End Sub Public Function GetArea() As Double GetArea = 4 * side End Function Public Sub Display() Console.WriteLine("Side: {0}", side) Console.WriteLine("Area: {0}", GetArea()) End Sub Shared Sub Main() Dim s As New Square() s.GetSide() s.Display() Console.ReadLine() End Sub End Class[/vbnet] Output: When developer execute the above code, then the output will be displayed as follows in the console.

Summary

shape Points

  • Dim gives memory allocation for variables.
  • To declare the name Sub will be used.
  • VB.Net is not a case sensitive.