Alright.

I'm going to just go through the VBA operators that we use to construct code.

How we multiply, and divide,

and do different functions in VBA is a lot like you do an Excel.

So, if you're quite familiar with Excel, it's almost the same.

There are few differences.

Also, if you have experience working with a programming calculator,

it's the same thing where you're working with the order of operations.

Shown here on this slide,

we have the order of operations, exponentiation comes first.

That's in contrast to Excel.

Excel actually is unique in that it does negation first.

So, if you did negative three caret two in Excel,

it will give you nine, which is a little bit counterintuitive,

but it negates first.

Whereas in VBA, it does the exponentiation first,

and then does the negation.

So, in VBA, negative three caret two would be negative nine.

Multiplication, division, or the asterisk,

and the forward slash,

you can do integer division using backslash.

There's really popular function called at least in this course,

it's popular, it's called mod.

So, that's the remainder.

For example, if we did five mod three,

that would give us two.

All right. So, it's going to be used quite a bit in this course.

Addition and subtraction, plus and minus,

if you're joining two strings or a string with a number,

you can use the ampersand,

which is this symbol.

That's joining two strings or joining a string and a number.

It's used a lot in message boxes and input boxes.

Relational operators, we have greater than,

less than, greater than or equal to,

less than equal to, equal,

and this is not equal to.

So, this is the equivalent of the not equal.

We'll do some logical examples here in this course.

We also have the not.

So, not true is false,

not false is true,

meaning it'll give you a true like if A and B are both true.

So, whatever comes before it and after,

it has to be both be true,

or means one or the other or both have

to be true in order for the combination to be true.

Then, something XOr something means Exclusively Or,

meaning you have to have a true and false or a false and true,

but you can't have both trues.

It has to be one has to be true, one has to be false.

VBA's got a lot of built-in functions.

Some of the most common ones are shown down here.

As I'm going to show in a future screencast and one of

the other screencasts is how you can use Excel's built-in functions.

So, in VBA, there's lot of these common functions.

We have the absolute value,

the square root, exponential.

Very importantly, the log function in VBA is the natural log.

The message box function and input box function are really important.

You've probably seen some of those in some examples

I've already gone through some of those screencasts in this module.

Let's go through a couple examples of how you would put this into VBA syntax.

If we had y plus 2 quantity times x minus two, over this denominator,

the way you do that in VBA,

you'd write it like this.

The way that VBA interprets it is it always does functions first.

So, it calculates a square root,

returns an answer to that position,

it then starts with parentheses, order of operations.

So, it computes the y plus two result,

then it computes the x minus two result.

It then multiplies those two to get a numerator result.

Then, it starts with a left on the denominator,

it calculates the x squared result,

and it computes the x times y result,

and adds up all three in the denominator,

and then it divides the numerator result

by the denominator result to get the final answer.

So, that's how VBA calculates these different things.

It's a lot like your programming calculator where it works left to right.

All right. Let's go through a couple more examples.

We have pi D squared over 4L.

There is no built-in pi function.

So, a good way to denote pi in VBA is to do four times the arc tangent of one.

So, the tangent of pi over four is equal to one.

So, you can use that property to define that as pi.

So, we can either write it like this.

So, this expression on the left would be written like that,

or if we don't use parentheses in the bottom,

we can divide twice because the way that VBA read syntax is left to right,

so we can do that.

This one, we would have T minus TL divided by quantity a times quantity TH minus TL.

So, you can denote,

you can force the order of operations using parentheses.

If we didn't want to use these outer parentheses here,

you can always do the same thing that we did above,

where you divide by a and then take that result and divide by TH minus TL in parentheses.

Another example that there's an error in this.

I want you to try to figure out what's the error in this.

So, what we don't have is an asterisk right there.

So, there should be an asterisk between the two in the left parentheses.

What about if we wanted to take the sine of 45 degrees?

Could we just use sine of 45?

Be careful because in VBA,

the sine, the trig functions,

the arguments have to be in radians.

So, if you wanted to do the sine of 45 degrees,

you'd have to first convert it to radians.

What about logarithms and exponents?

Well, the natural log of y,

so we could take the exponential of both sides of this equation,

and we get the right-hand side.

So, remember that property.

The natural log is the log functions.

So, if you wanted to use natural log, it's just LOG.

The exponential function is just EXP of x.

If we wanted to write this,

we could do just some properties.

You can take 10 to the both sides of this equation.

This is Antoine equations,

some of you might recognize.

To write this in VBA,

we would have to do a change of base,

take log of the number divided by log of the base,

and that is equal to in this case,

LOG 10 of P. We could write this expression,

10 caret in parentheses A minus B divided by quantity T plus C. So,

that's it for basic expressions in VBA. Thanks for watching.