Translate

Tuesday, 28 May 2013

Arithmetic Operator and Assignment Operator in VB.NET

Introduction to VB.NET Programming II

In the previous blog we one datatype and variable now we will see operators in VB.NET.

First we will see Arithmetics Operators and Assignment Operator.

Arithmetic Operators

Addition  : +
Subtraction : -
Multiplication : *
Division : /


Assignment Operator

Equal : =


We will see example programs  of these operators.

Example Program-2

Module Example2
  Sub main()
  Dim Num1, Num2 As Integer
  Dim AddResult, SubResult, DivResult, MulResult As Integer
  Num1 = 100
  Num2 = 25
 
  AddResult= Num1 + Num2
  SubResult= Num1 - Num2
  DivResult= Num1 / Num2
   MulResult = Num1 * Num2
 
  Console.Writeline("Addition : " &AddResult)
  Console.Writeline("Subtraction : " &SubResult)
  Console.Writeline("Division : " &DivResult)
  Console.Writeline("Multiplication : " &MulResult )
 
  Console.ReadKey()

  End SubEnd ModuleIn the above program  we declared two variable for assigning Values and four variables for getting result of four arithmetic operations and the results are displayed on the screen.   Console.Writeline function display output and goes to next line the difference between Console.Write and Console.Writeline is first one display output and does not go to next line but the later one display output and moves to next line.
We will see more examples using Arithmetic operators in the next blog.       
       

       








No comments:

Post a Comment