Skip to main content

Operators in VB.NET

A special symbol that provides certain process according to requirement is known as operator.
Information is not extremely useful if you can’t do anything with it. Operators perform actions on values, producing a result. For example, the addition operator (+) takes two numbers and adds them together.
It has mainly two types of operator:
1.      Unary operator
2.      Binary operator

Unary Operator
An operator that acts on one operand is called a unary operator.
Example: -10
Binary Operator
An operator that acts on two operands is called a unary operator.
Example: 15 - 10
It has some sub operators:
1.      Arithmetic operators
2.      Comparison operators
3.      Logical operators
4.      Concatenation operators
5.      Miscellaneous operators

Arithmetic Operators
Purpose: To perform arithmetic process
Operators
Symbol
Addition
+
Subtraction
-
Multiplication
*
Division
/
Modulus
Mod
Equal to
=

Relational Operators
Purpose: To compare values, expression or variable for taking decision and other process.
Operators
Symbol
Less than
<
Less than equal to
<=
Greater than
>
Greater than equal to
>=
Not equal to
!=

Logical/Bitwise Operators
Purpose: To set some boundary according to a specific condition.
Operators
Symbol
AND
(compulsory True)
and
OR
(Optional any one)
Or
AND ALSO
(If first is false then no further checking will be performed)
and also
OR ELSE
(If first expression is true, then no further checking)
or else


Example: and also
Dim a = 10, b AsInteger = 20
If a < 5 AndAlso b > 10 Then
      Label1.Text = "Match"
Else
      Label1.Text = "Not match"
EndIf

Example: or else
Dim a = 10, b AsInteger = 20
If a > 4AndAlso b > 10 Then
      Label1.Text = "Match"
Else
      Label1.Text = "Not match"
EndIfc

Concatenation Operators
Purpose: To join two or more String
It uses “&”and “+” operator to perform its task.
Example:
Msgbox(“First name = “ & textbox1.text & “ Middle name = “ & textbox2.text )

Miscellaneous Operators
Purpose: For special operation or process
1.     Shorthand operators

a += 6 means a = a + 6
a -= 6 means a = a - 6
a *= 6 means a = a * 6
a /= 6 means a = a / 6

Note:In .net a++ (postfix) and ++a (prefix) is not available.

2.     Datatype presenter
gettype()
Example:
Dim a as integer
msgBox(a.GetType().ToString)

It will print System.Int32


Posted By: Chaudhary Amit V.

Comments

Popular posts from this blog

Characteristics of a Good Programming Language

Till now there are many high level languages which are very popular, and there are others, which could not become so popular in-spite of being very powerful. There might be many reasons for the success of a language, but one obvious reason is the characteristics of the language. Several characteristics believed to be important with respect to making a programming language good are briefly discussed below. Simplicity A good programming language must be simple and easy to learn and use. For example, BASIC is liked by many programmers only because of its simplicity. Thus, a good programming language should provide a programmer with a clear, simple and unified set of concepts which can be easily grasped. It is also easy to develop and implement a compiler or an interpreter for a programming language that is simple. However, the power needed for the language should not be sacrificed for simplicity. The overall simplicity of a programming language strongly affects the readability of the pr...

Angular 4 and Firebase Authentication: Setup

If you have come to this article, it means you are keen to learn new technology and that too Firebase. I love Firebase because it provides all basic but important features of any web application. Take for example, authentication, which is cumbersome and risky if not implemented with utmost care. And when we have the integration of Angular and Firebase, it becomes a lot easier for a developer to build such crucial modules in less time with minimal efforts. In this article we will create a simple Angular application using Firebase. I am going ahead with the understanding that you know the benefits of Firebase and have little knowledge about it. There are plenty of posts out on the web if you are behind. Step 1: Install Angular CLI (if not installed). npm install -g angular-cli Step 2: Create new Angular 4 project. By default now angular CLI will create Angular 4 project so you need not fret. ng new firebase-authentication Step 3: Check whether the ne...

Switch-case, simple calculator . . .

11.      Write a program to perform some mathematic functions with the help of “switch-case” statement. #include<stdio.h> #include<conio.h> void main() { int a,b,ans; char c; clrscr(); printf("\ Enter a and b:"); scanf("%d%d",&a,&b); printf("\n Enter operator:"); fflush(stdin); scanf("%c",&c); switch(c) { case'+':ans=a+b;       break; case'-':ans=a-b;       break; case'*':ans=a*b;       break; case'/':ans=a/b;       break; } printf("\n ans %d",ans); getch(); } 12.      Print the Fibonacci series #include<stdio.h> #include<conio.h> void main() { int a=1,b=1,s=3,c,ch; clrscr(); printf("how many steps="); scanf("%d",&ch); printf("%5d%5d",a,b); for(s=3;s<=ch;s++) {       c=a+b;       printf("%5d",c);       a=b;    ...