Sunday 12 March 2017

ArithmeticOperator in VB Script

In this operator we use it for addition, subtraction etc.

Let Assume, a=5 and b=2

1-Adds two operands (+)
This operator is used to add (Sum) two values.

Ex-
                a=5
                b=2
                sum= a+b
               msgbox "Sum is = " & sum

Output-
                Sum is = 7


2-Subtraction (-)
Subtracts second operand from the first.

Ex-
                a=5
                b=2
                sub=a-b
                msgbox "value is = " &sub

Output-
              Value is = 3


3-Multiply (*)
This operator is used for multiple two values.

Ex-
                a=5
                              b=2
                multi=a*b
                msgbox " Value is = " &multi

Output-
              Value is = 10

4- Divide (/)
Divide Numerator by Denumerator.

Ex-
                 a=5
                 b=2
                div=a/b
               msgbox "value = " &div

Output-
              Value is = 2.5

5- Modulus (%)
Modulus Operator and remainder of after an integer division.

Ex-
                 a=5
                 b=2
                 mo=a mod b
                 msgbox "mod value is = " &mo

Output-
             mod value is = = 1

6-Exponentiation ( ^ )
Ex-
                    a=5
                    b=2
                   exp=a^b
                  msgbox "Exponentiation value = "& exp

Output-
              Exponentiation value = 25


No comments:

Post a Comment