Expressions and Operators in VB.NET

Drawing Denso QR Bar Code in VB.NET Expressions and Operators
Expressions and Operators
QR Code JIS X 0510 Creation In VB.NET
Using Barcode generation for .NET Control to generate, create QR Code image in Visual Studio .NET applications.
An expression can always be used in the same place as a single value in a statement For example, the expression 4 + 3 can be used anywhere we could use the individual number 7 in a program Since either of the numbers in that expression could also
Draw Barcode In Visual Basic .NET
Using Barcode generator for .NET Control to generate, create barcode image in VS .NET applications.
33 Expressions and Operators
QR Code ISO/IEC18004 Drawer In C#
Using Barcode generator for Visual Studio .NET Control to generate, create Denso QR Bar Code image in .NET framework applications.
be replaced by an expression we can use an expression of any complexity in any place in a program where a value would do For example 4 + 3 is the same as (2 * 2) + 3 and both are the same as Sqr(16) + 3 In fact, a single value is simply another form of expression The notion of an expression in a program is therefore a very powerful thing, since an expression can be of any complexity, and yet can always be used in any situation where we might make use of a value For example, consider the operation of displaying a single value on the screen of a console program Looking back to any of the code examples we ve seen so far in this chapter, you will see that the general form for displaying a value is:
Encode QR Code 2d Barcode In VS .NET
Using Barcode creation for ASP.NET Control to generate, create QR Code ISO/IEC18004 image in ASP.NET applications.
ConsoleWriteLine("Here comes some value: {0}", value)
Quick Response Code Creator In Visual Studio .NET
Using Barcode printer for .NET Control to generate, create QR image in Visual Studio .NET applications.
ConsoleWriteLine("Here comes some value: {0}", 42)
Bar Code Encoder In VB.NET
Using Barcode creator for VS .NET Control to generate, create barcode image in .NET framework applications.
In the rst case, we re displaying the current contents of a variable, value In the second we re displaying a literal value However, either of these could be replaced by an expression of arbitrary complexity:
Making Barcode In VB.NET
Using Barcode generator for .NET Control to generate, create barcode image in .NET applications.
ConsoleWriteLine("Here comes some value: {0}", _ value1 * value2 + value3 / value4)
ANSI/AIM Code 39 Encoder In VB.NET
Using Barcode printer for VS .NET Control to generate, create Code 3/9 image in Visual Studio .NET applications.
(Note, the sequence of a space followed by a _ at the end of a line allows us to run over on to the next line in a VB program) Replace any of value1, value2, value3 or value4 by another expression and the whole thing is still an expression We can also do the same in any other place we would normally use a value For example:
Draw Code 128 Code Set C In Visual Basic .NET
Using Barcode drawer for .NET framework Control to generate, create Code 128 Code Set C image in VS .NET applications.
y = Sqr(a + b + c)
Paint DataMatrix In VB.NET
Using Barcode drawer for .NET framework Control to generate, create Data Matrix 2d barcode image in .NET framework applications.
Here the expression a + b + c is evaluated as a single value, that is then passed to the built-in Sqr() function We could even do:
Scan Barcode In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
y = Sqr(Sqr(256))
Paint Code39 In Visual C#
Using Barcode creator for VS .NET Control to generate, create Code39 image in Visual Studio .NET applications.
since the expression Sqr(256) evaluates as a single number (16) which can be passed to the Sqr() function Overall, that statement has exactly the same result as:
Barcode Drawer In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create bar code image in ASP.NET applications.
y = 4
Paint Barcode In Java
Using Barcode generation for Java Control to generate, create bar code image in Java applications.
Expressions always involve values, either literal ones or values stored in variables However, they also, except in the case of the simplest expressions (a single value), involve either functions or operators Visual Basic contains a large number of operators for use in a wide range of situations Table 33 shows most of the available operators
Data Matrix Scanner In VS .NET
Using Barcode decoder for .NET framework Control to read, scan read, scan image in VS .NET applications.
Table 33
Bar Code Drawer In Java
Using Barcode maker for Java Control to generate, create barcode image in Java applications.
3 n The Visual Basic NET Language
Create EAN-13 In Visual Studio .NET
Using Barcode generator for ASP.NET Control to generate, create GTIN - 13 image in ASP.NET applications.
Standard operators in Visual Basic
Code 128 Code Set C Drawer In .NET
Using Barcode encoder for .NET framework Control to generate, create ANSI/AIM Code 128 image in Visual Studio .NET applications.
Operator
Creating Code 39 Full ASCII In Java
Using Barcode creator for Java Control to generate, create USS Code 39 image in Java applications.
Meaning
Barcode Generator In .NET Framework
Using Barcode creation for Visual Studio .NET Control to generate, create barcode image in .NET applications.
Example
Arithmetic operators (simple calculations) +, , *, / Standard arithmetic ie Plus, Minus, Times, Divide symbols eg x = (y * z) / 4 (Note that *, not x, is used for multiplication) \ Mod ^ Integer division Modulus remainder after division Exponentiation (power) 11 \ 3 11 mod 3 X^3 Division with integer result (ie the fractional part of the result is discarded here result is 3) Result is remainder of 11\3, or 2 Result is X raised to the power 3
Assignment operators (all assign a new value to the variable on the left) = Simple assignment X=3 Assign a new value to variable X += = *= /= \= ^= &= Increment Decrement Multiply and assign Divide and assign Integer divide and assign Raise to power Concatenate X += 3 X =3 X *= 3 X /= 3 X \= 3 X ^= 3 X &= abc Increases the value of the variable X by the 3 Decreases the value of the variable X by the 3 Multiply the value of the variable X by 3 and assign the result to X Divide the value of the variable X by 3 and assign the result to X Divide the value of the variable X by 3 and assign the integer part of the result to X Raise X to the power 3 and assign the result to X Attach the string abc to the end of the string variable X
Comparison operators (all give a Boolean result) < Less than X<Y > = <= >= Greater than Equal to Less or equal Greater or equal X>Y X=Y X <= Y X >= Y
True if X is less than Y True if X is bigger than Y True if X and Y are equal note, this is distinguished from the assignment = by context True if X is not bigger than Y True if X is not less than Y
Logical operators (used to combine simple Boolean expressions) And Logical And X And Y True if both X and Y are True Or Not Xor Logical Or Logical inversion Exclusive or X Or Y Not X X Xor Y True if either X or Y is True True if X is False, False if X is true True if X is True and Y is False or if X is False and Y is True False otherwise