Page 198 - DCAP408_WEB_PROGRAMMING
P. 198

Web Programming




                    Notes
                                       Operator        Function                Example               Result
                                           =           Equal to                 9 = 10                False
                                           <           Less than        aNumber = 5, aNumber < 10     True
                                           >          Greater than      aNumber = 5, aNumber > 10     False
                                          <>          Not equal to              5 <> 10               True

                                   Logical Operators

                                   Logical operators take the result produced  by comparison operators and  compares them to
                                   create new true or false values. For example, true AND false = false.

                                     Operator                Function                   Example       Result
                                     AND        True if both are true, otherwise false   9 = 10 AND 10 = 10   False
                                     OR         True if at least one is true, otherwise false   9 = 10 OR 10 = 10   True
                                     Not        Reverses truth value                5 = 5             False

                                   String Operators


                                   There is only one string operator and that is the concatenation operator”&”. This operator is
                                   used to combine text strings.


                                          Example:  <% Dim stringOne = “This is “ Dim stringTwo = “a text string”
                                   Response.  Write  (stringOne  &  stringTwo  &  “<br  />”)  Response.Write(“ASP
                                   stands  for  “  &  “Active  “  &  “  Server  “  &  “  Pages  “)  %>
                                   Output:
                                   This is a text string ASP stands for Active Server Pages

                                   7.5 ASP Conditional Statement

                                   When performing  assignments using code, sometimes  you must  find out  whether  a  given
                                   situation bears a valid value. This is done by checking a condition. To support this, VBScript
                                   provides a series of words that can be combined to perform validations. Checking a condition
                                   usually produces a True or a False result. Once the condition has been checked, you can use the
                                   result (as True or False) to take action. Because there are different ways to check a condition,
                                   there are also different types of keywords to check different things. To use them, you must be
                                   aware of what each does or cannot do so you would select the right one.

                                   The Boolean Type

                                   Sometimes, you may want to store the result of a condition, being true or false, in a variable.
                                   To do this, you can declare a variable that would hold a Boolean value. Here is an example of
                                   declaring a Boolean variable when the form opens:
                                   Dim IsMarried

                                   When a Boolean variable has been declared, you can assign it a True or a False value.
                                   To convert a value or an expression to Boolean, use the CBool() function.
                                   Techniques of Checking a Condition



          192                               LOVELY PROFESSIONAL UNIVERSITY
   193   194   195   196   197   198   199   200   201   202   203