Operator In Visual Basic
SESSION:-2023-24
INDEX
1. Operators
2. Types of operators-
i. Arithmetic operators
ii. String or Concatenation operator
iii. Comparison operators
iv. Logical operators –
a. AND operator
b. OR operator
c. Not operator
d. EQV operator
e. XOR operator
OPERATORS
• An operator is a code element that performs an operation on
one or more code elements that hold values.
• Value elements include variable, constants ,literals and
properties, are expressions returned form function and operator
procedures.
• An expression is a series of value elements combined with
operators , which yields a new value.
• The operators act on the value elements by performing
calculations, comparisons, or other operations.
TYPES OF OPERATORS
• Arithmetic Operators
• String or Concatenation Operator
• Comparison Operators
• Logical Operators
Arithmetic operators are used always the arithmetic expression.
These are various types of arithmetic operators in visual basic.
Arithmetic Operators
Operators Function Example Result
+ Addition 5+10 15
- Subtraction 10-5 5
/ Divide 25/5 5
 Integer
Division
203 6
* Multiply 5*4 20
^ Exponent 3^3 27
Mod Remainder
of division
20 Mod 6 2
Example
STRING OR CONCATENATION OPERATOR
The concatenation operator & is used to concatenate two or
more string. For example ,“a” & “b” will return “a b” , the
concatenated string:-
Example -
str1 = “Mr.”
str2 = “Shobhit”
str3 = “Sexena”
Name = str1 & “ “ & str2 & “ “ & str3
MsgBox(Name)
The above code will display a message box with :
Mr. Shobhit Sexena
Comparison Operators
Comparison operators compare two expression and return a
Boolean value representing the result of the comparison.
These are kept in the category of relational operators.
Operator Comparison Example
> Greater than a>b
< Less then a<b
>= Greater then
or equal to
a>=b
<= Less then or
equal to
a<=b
= Equal to a=b
<> Not equal to a<>b
Example
If(mark>40)then
MsgBox”Passed”
Else
MsgBox”Failed”
End if
Logical Operators
The operators used to take decision in programming is know as
logical operators.
OPERATORS OPERTION
And Logical And
Or Logical Or
Not Logical Not
Eqv Equivalent
XOR Logical XOR
AND Operators
In visual basic and operator is used to add the expression by
comparison . It mean that it checks both the status given in the
application expression and works only if both are true by this
operator. The result of addition of the expression is expressed
in the following test.
Expression-1 Expression-2 Result
1 1 1
1 0 0
0 1 0
0 0 0
OR Operators
In visual basic OR operator is used to logical check the truthiness
of any one among two expression . This operator works it any
one status or both the status of the expression is true.
Expression-1 Expression-2 Result
1 1 1
1 0 1
0 1 1
0 0 0
N0T Operator
In visual basic Not operator is used to check the truthiness of
any one expression among two expression . This operator
works if the first status among the two expression is true.
Expression-1 Result
1 0
0 1
EQV operator
In visual basic EQV operator is used to check the logic
equality between the two expression this operator works if the
status of both the expression is either true or false.
Expression-1 Expression-2 Result
1 1 1
1 0 0
0 1 0
0 0 1
XOR Operator
In visual basic this operator is used to logical check the
truthiness of among two expression oppositely. This operator
works only if any one status among the two expression is true.
Expression-1 Expression-2 Result
1 1 0
1 0 1
0 1 1
0 0 0
operat in vb .pptx

operat in vb .pptx

  • 1.
    Operator In VisualBasic SESSION:-2023-24
  • 2.
    INDEX 1. Operators 2. Typesof operators- i. Arithmetic operators ii. String or Concatenation operator iii. Comparison operators iv. Logical operators – a. AND operator b. OR operator c. Not operator d. EQV operator e. XOR operator
  • 3.
    OPERATORS • An operatoris a code element that performs an operation on one or more code elements that hold values. • Value elements include variable, constants ,literals and properties, are expressions returned form function and operator procedures. • An expression is a series of value elements combined with operators , which yields a new value. • The operators act on the value elements by performing calculations, comparisons, or other operations.
  • 4.
    TYPES OF OPERATORS •Arithmetic Operators • String or Concatenation Operator • Comparison Operators • Logical Operators
  • 5.
    Arithmetic operators areused always the arithmetic expression. These are various types of arithmetic operators in visual basic. Arithmetic Operators Operators Function Example Result + Addition 5+10 15 - Subtraction 10-5 5 / Divide 25/5 5 Integer Division 203 6 * Multiply 5*4 20 ^ Exponent 3^3 27 Mod Remainder of division 20 Mod 6 2
  • 6.
  • 7.
    STRING OR CONCATENATIONOPERATOR The concatenation operator & is used to concatenate two or more string. For example ,“a” & “b” will return “a b” , the concatenated string:- Example - str1 = “Mr.” str2 = “Shobhit” str3 = “Sexena” Name = str1 & “ “ & str2 & “ “ & str3 MsgBox(Name) The above code will display a message box with : Mr. Shobhit Sexena
  • 8.
    Comparison Operators Comparison operatorscompare two expression and return a Boolean value representing the result of the comparison. These are kept in the category of relational operators. Operator Comparison Example > Greater than a>b < Less then a<b >= Greater then or equal to a>=b <= Less then or equal to a<=b = Equal to a=b <> Not equal to a<>b
  • 9.
  • 10.
    Logical Operators The operatorsused to take decision in programming is know as logical operators. OPERATORS OPERTION And Logical And Or Logical Or Not Logical Not Eqv Equivalent XOR Logical XOR
  • 11.
    AND Operators In visualbasic and operator is used to add the expression by comparison . It mean that it checks both the status given in the application expression and works only if both are true by this operator. The result of addition of the expression is expressed in the following test. Expression-1 Expression-2 Result 1 1 1 1 0 0 0 1 0 0 0 0
  • 12.
    OR Operators In visualbasic OR operator is used to logical check the truthiness of any one among two expression . This operator works it any one status or both the status of the expression is true. Expression-1 Expression-2 Result 1 1 1 1 0 1 0 1 1 0 0 0
  • 13.
    N0T Operator In visualbasic Not operator is used to check the truthiness of any one expression among two expression . This operator works if the first status among the two expression is true. Expression-1 Result 1 0 0 1
  • 14.
    EQV operator In visualbasic EQV operator is used to check the logic equality between the two expression this operator works if the status of both the expression is either true or false. Expression-1 Expression-2 Result 1 1 1 1 0 0 0 1 0 0 0 1
  • 15.
    XOR Operator In visualbasic this operator is used to logical check the truthiness of among two expression oppositely. This operator works only if any one status among the two expression is true. Expression-1 Expression-2 Result 1 1 0 1 0 1 0 1 1 0 0 0