15.04.2018 Views

programming-for-dummies

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

596<br />

Using Operators<br />

In REALbasic, you can declare a constant without the data type declaration,<br />

such as<br />

Const Pi = 3.14<br />

Using Operators<br />

The three types of operators used are mathematical, relational, and logical.<br />

Mathematical operators calculate numeric results such as adding, multiplying,<br />

or dividing numbers. Table 5-5 lists the mathematical operators used in<br />

Visual Basic and REALbasic.<br />

Table 5-5<br />

Mathematical Operators<br />

Mathematical Operator Purpose Example<br />

+ Addition 5 + 3.4<br />

- Subtraction 203.9 - 9.12<br />

* Multiplication 39 * 146.7<br />

/ Division 45/ 8.41<br />

\ Integer division 35 \ 9 = 3<br />

Mod Modula division (returns the remainder) 35 mod 9 = 8<br />

^ Exponentiation 2 ^ 4<br />

Relational operators compare two values and return a True or False value.<br />

The six relational operators available in Visual Basic and REALbasic are<br />

shown in Table 5-6.<br />

Table 5-6<br />

Relational Operators<br />

Relational Operator Purpose<br />

= Equal<br />

Not equal<br />

< Less than<br />

Greater than<br />

>= Greater than or equal to<br />

Logical operators compare two Boolean values (True or False) and return<br />

a single True or False value. Both Visual Basic and REALbasic use the same<br />

logical operators but Visual Basic includes two additional operators —<br />

AndAlso and OrElse, as shown in Table 5-7.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!