 Welcome back to another video. This video is gonna feature a couple of topics that we've already been over, but actually bringing them together to actually create a more advanced calculator than we've previously looked at. So what we're gonna do is obviously combine the input boxes and the if function that we recently learned together, like I say, to make a more advanced calculator that we've previously built in past videos. So we'll jump straight into it. So the first thing we need to do, obviously we've got our module here and we've inserted that by this drop down box atop here. What we're gonna do is we'll do our subroutine and we're gonna call this one simple calculator. Calculator, calculator, if I can spell calculator, not that it matters too much, but here we go and we can jump straight into coding this. So the first thing we need to do is we're gonna have two numbers and just to explain how our calculator will work, we'll ask the user to input two numbers and we'll also be asking the user to provide a symbol, so a plus, minus, division or multiplication. And then obviously our calculator will then perform the desired calculation based on the symbol that they've provided, obviously using the two numbers they've entered as well. So we're gonna first define our variables. So the first ones are gonna be our numbers. So we'll do dim number one as integer and we'll also do number two as integer as well. The second part is our symbol. So this is gonna be stored as a string. So for this we'll do dim, not sim, dim and we'll call it sim one as string. And that is all of our variables that require that being defined. This next part you can do in any order you wish. You could have the user first input the two numbers and followed by the symbol. But for this I'm just gonna do it in the same format you would use a calculator. So you'd enter number one, your symbol, followed by then your second number to obviously do perform the calculation. So we'll do number one and this equals input box. So we're actually gonna ask, they'll have an input box or pop up onto the screen asking the user to enter this information or this number and we'll do enter first number. So that's obviously the prompt they'll have on their input box. The second one is going to be sim one and this will also be the same. So it equals input box and enter calculation symbol. Obviously trying to keep it nice and descriptive so the user knows what they're being asked to enter. And the last one is then gonna be number two and this will also be input box enter second number. So obviously as I've entered these, this is the order that the input boxes will be popping up. So like I said, if you want to have your first, the first two pop ups to be your numbers, obviously you just order this number one, number two with symbol one at the end. But obviously I've just done this as I mentioned just to keep the same usual format you'd see from a calculator. So once all three of those input boxes have popped up and the user has entered their information, we now need to obviously take that information and perform our calculation. So the first thing we're gonna be, well we're gonna be obviously using our if statement and so we now need to go through all the different iterations of the symbols that they could be entering and different calculations performed based on that symbol. So the first one is gonna be if and sim one equals and in quotations plus. So we know that if they enter the plus symbol then they want to do an addition. So we then go then go indent into the line as well. So if they've entered the plus, then what we need to do is we'll do a message box just to keep this nice and simple. So we're not gonna be stored on the value anywhere. We're literally gonna just display the result of that calculation in the message box and that's it, that'll be the end of the routine. So if they've entered the plus symbol then our message box needs to be number one plus number two. And when I say what our message box needs to be it just means that that's the value or the result of num one plus number two is the result our message box will be showing. If they haven't entered the plus symbol then we'll do else if sim one equals a minus symbol. And then this time obviously the similar format or very much the same format is gonna be msg box is therefore gonna be number one minus number two. So obviously that's the result it will present. So if it's not a plus or it's not a minus then it could be else if sim one is equal to a division. Then it's just doing obviously a slash there. Then message box is going to be number one divided by number two. And the last one of our symbols will then do else if sim one is equal to a multiplication symbol. And obviously not to get mistaken with the X we need to be using the asterisk so you can either do shift eight or if you've got the additional panel keyboard to the right you'll have that multiplication symbol there as well. And then do then message box. The result should be or the value presented in that message box should be number one times by number two. So that covers off all of our symbols. So we've got the four symbols, got the addition, the minus, the division and the multiplication. So if they haven't entered one of those values so there's the value stored in sim one is not one of those symbols. We're then gonna just use an else statement and say message box enter a valid symbol. And then once we've done that we can then do end if and that is it. So just to talk through obviously what we have here now. So first we've defined obviously all of the variables that we're going to be using. Once we've done that, we're then gonna be able to store the value for each one of those variables and each one of those or every one of those is gonna be stored by the use of an input box. So obviously number one, the first thing will happen will be an input box asking them to enter their first number and that will get stored as number one. The second input box will ask them to enter their calculation symbol and that will be stored as sim one. And the last one that we've got number two that being input box asking them to store or enter a second number to be stored in sum number two. Obviously once we've done that we're then using the if function to perform a number of if statements to identify what symbol they have entered. Obviously depending on the symbol entered will then perform the appropriate calculation. So the addition, the minus, the division and the multiplication. If however they haven't entered a symbol or they've given a non-valid symbol such as a letter or any other symbol available on the keyboard then we'll say okay well we need to present a message box that says enter a valid symbol. So no calculation be performed they will just receive a message box saying enter a valid symbol. So what we'll do we'll run through this from like maybe five examples just to test each one of those scenarios. As always to run this we can either do this using F5 or our play button here. I will just be doing F5 as it's just a lot quicker and easier to do. So if I hit F5 we can see we've got our first input box so enter your first number. I'm going to enter number five. We'll click okay. The next thing we'll ask is to enter calculation symbol. So let's do a plus symbol. Okay. And then we'll ask to enter our second number. Go to number five. So we're going to be doing this very first functional scenario at the top here. Okay. So yeah we can see we've got the result of 10. So five plus five is obviously equal to 10. If we then to run that obviously when you then do that last message box will give you the result as soon as you click okay. Obviously it's then going to the sub routine is then finished and you're then out of the routine. So that's then all done. Let's run this again. So let's do now maybe 10. And I'm just going to hit the enter button because you can see obviously the okay is already selected rather than use the mouse you can just use the enter button. So my calculation symbol I'll do a minus. And then this time let's do the number three. So we can see it's correctly performed our subtraction. We'll go into it again. And this time we'll do 10 and we'll say divided by two. And that gives us the value of five brilliant. Then we'll go one more. We've got the first number is five. This time we'll do a multiplication. So we've got that multiplication symbol enter and five. Yet correctly gives us the value of 25. And then the last scenario is if we now go into this and we go let's say number five but this time we enter an incorrect symbol. So let's say a question mark or it could be anything just basically anything other than a symbol is going to cause this scenario. You enter and then we'll go into five again. You can say we've now got the message box there saying enter a valid symbol. So obviously the calculation hasn't been able to do basically hasn't been able to calculate because the symbol was invalid. So if you do okay, you can say again we've now come out of the routine. So this is how we can create a more advanced calculation than what we've previously looked at in this series. Obviously there's an additional logic you could apply here if you so wish such as if a number or one of those number input boxes if someone doesn't input a number they put something else then obviously you could put some validation that says enter a valid number. And obviously that then exit the sub routine at the point of entering. And many other options are available to you and you can customize this as you so require. So that concludes this video creating that more advanced calculation. I hope you enjoyed that video. If you did, please do give the video a like. We greatly appreciated by myself. It was the first time again coming across the channel or you haven't watched our videos before. Please do hit that subscribe button and also make sure you hit that notification button so you're notified of all of our new videos as they come out. As always, if you have any questions please just drop me a comment below this video and I'll get back to you as soon as I can. So again, thank you very much for watching and we'll see you in the next video.