Showing posts with label Expressions. Show all posts
Showing posts with label Expressions. Show all posts

Wednesday, October 27, 2010

Comparison Operators / Relational Operators

Comparison operators are used to compare values.

=  : Equality
<>  : Inequality
 > : Greater than
 < : Less than
 >=  : Greater than or equal to
 <= : Less than or equal to

Logical Operators

Logical operators perform conditional and, or, and not operations

And          : Used to evaluate two operands(values) as being true (or false)
Or            :
Used to evaluate one or more operands(values) as being true (or false)
Not          :
Used to evaluate whether an operand(value) is not true (or not false)

Expressions

An expression in a programming language is a combination of values, variables, operators, and functions that are evaluated to produce another value.

Subtraction

Code eg: Subtraction from two integer variables

' Declare variables
Dim TotalPointsPossible As Integer = 200
Dim TotalPlayerMisses As Integer = 50
' Create the expression
Dim TotalScore As Integer = TotalPointsPossible - TotalPlayerMisses

                    The expression in the example will evaluate to 150.

Addition



Code eg: Addition of two integer variables.

' Declare variables
Dim RoundOneScore As Integer = 5000
Dim RoundTwoScore As Integer = 4678
' Create the expression
Dim TotalScore As Integer = RoundOneScore + RoundTwoScore

                    The expression in the example will evaluate to 9678