VB.net

a quick and convenient way to build a window based application. basically there is two main components in VB, the design view where we place the controls on a window form. then we have the code view where we write implementation for each controls on the form. Typically the control implementation or procedures are executed when certain events happens to the controls. Events like mouse click, or value change on text box, form load, form close and so on.

After working with programming language like C, C++ and Java, getting use to VB is a bit challenging. its because first of all, VB don't use curly bracket to specify code blocks, and the statements don't end with semicolon.

variable declaration for example is written as

dim age As Integer

in C, C++ and Java it written

int age;

in VB, variable declaration start with dim keyword, it means dimension

and the functions are written as

Function addNumber(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
addNumber = num1 + num2
End Function

and in other language

int addNumber(int num1, int num2){
return num1 + num2;
}

and yes, in VB we can use the function  name to return values, or you can use the return keyword as we use to do in other languages.

array are declared like this

Dim cars(4) As Integer

this is similar to following java code

int[] cars = new int[5];

in VB, the number 4 is not the array size, its the last index number. Both the examples has five elements. In java the number 5 is the size of array.

If statements

If age > 21 And name = "Civa" THen
Console.WriteLine("Civa already more than 21");
Else
Console.WriteLine("Have not meet condition yet");
End If

in java

if (age > 21 && name.equals("Civa")){
System.out.println("Civa already more than 21");
}else{
System.out.println("Have not meet condition yet");
}

the for loop

For a = 1 To 10
Console.WriteLine(a)
Next

java

for(int a = 1; a <=10; a++){
System.out.println(a);

}

Comments

Popular posts from this blog

Drawing Simple Pie Chart

VB.net connecting to SQL Server