CHAPTER 7 - CALC OPERATORS



AD

7.1 Operators

Operators include symbols for multiplication, division, addition, and subtraction. Operator precedence is the order in which operations are performed. The following is an operator precedence chart.

LibreOffice Calc operators.

LibreOffice Calc comparison operators.

There are also logical operators which allow more than one condition on the same line. The following chart is a summary of Logical operators.



LibreOffice Calc logical operators.

The following program illustrates logical and comparison operators. The first two lines are True, and the third line is False.

Sub myOperators()
If 4 > 3 And 2 < 7 Then MsgBox “Message Box 1 is True”
If 2 >= 2 Or 7 > 3 Then MsgBox “Message Box 2 is True”
If 7 > 2 And 8 > 9 Then MsgBox “Won’t print”
MsgBox “ Above statement is False”
End Sub

The following examples illustrate precedence of operators.

Sub myPrecedence()
Dim x As Double      REM Double is for decimals.
Dim y As Double
Dim z As Double
x = 2 * 3 + 4 / 2 - 3 + 2 ^ 3      REM x = 13
MsgBox “x = “ + x
y = 2 * (3 + 4) / 2 - 3 + 2 ^ 3      REM y = 12
MsgBox “y = “ + y
z = 2 * (3 + 4) / (2 - 3) + 2 ^ 3      REM z = -6
MsgBox “z = “ + z
End Sub




theSurfDragon.com


Calc Navigation

Table of Contents
Ch1-Introduction
Ch2-Loops
Ch3-If Statements
Ch4-Functions
Ch5-Subs & Functions
Ch6-Read & Write
Ch7-Operators
Ch8-Built-in Functions
Ch9-Built-in Examples
Ch10-Debugging
Ch11-Running Subs
Ch12-Sample Programs
Ch13-WS Formulas
Ch14-WS Functions
Ch15-Calc Help Page