We will do a basic review of exponential forms in Calc.
.000123 = 1.23E-4
12536 = 1.2536E4
12.345 = 1.2345E1
Be careful. LOG in Macro returns the natural logarithm of a number. (Notice that this is different from the Worksheet, where LOG signifies Log base 10.) To get the base 10 logarithm we must divide the natural log by 2.303.
LOG(15.3) = 2.727853 (In Basic Log() returns the natural logarithm.)
2.727853 / 2.303 = 1.184478 (This is the base 10 logarithm of 15.3.)
You must supply the angle in radians for all Calc trigonometric functions.
Radians = Degrees * Pi/180 Where Pi = 3.1416
Cosine of 30 degrees = Cos(.5236) in radians = .866
Here are some examples of how to change the format of numbers in Calc.
Sub myFormat()
MsgBox FORMAT(222.6, "Standard") REM 222.60
MsgBox FORMAT(0.771, "Percent") REM 77.10%
MsgBox FORMAT(1437.5, "Currency") REM $1,437.50
MsgBox FORMAT(126345, "Scientific") REM 1.26E+05
MsgBox LOG(15.3) REM Natural Log of 15.3 is 2.73
MsgBox TAN(PI/4) REM TAN of 45 degrees
MsgBox ABS(-9) REM 9
End Sub
In the program above we tested the functions FORMAT, LOG, TAN, PI, and ABS. Many of the worksheet functions do not work in Basic program macros. So if you are not sure if a builtin function works properly, test it.
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