All right, we're going to be working with this example. This was from one of the assignments in part one of the course. We've got this vertical tank. It's got hemispherical ends. And we want to know, we want to be able to output the volume as a function of depth little d in this tank. And we know the height and the radius of the tank. And it's piece wise, there are three different pieces. So if the diameter is less than or equal to the radius, we are somewhere down in here. And we've got this equation we're going to use. If we're at a depth between the radius and H minus R, so right here, then we're going to be using the second piece. And then if we're above that, we're going to be using this third piece to output the volume. Now, on the course website, I've got this TankForm- STARTER.xlsm. I've already put everything here. I've included a picture. I think it'll look a bit better on your computer. I have a Surface Pro and the resolution is really high. So I think on some of your normal computers, this might be bigger. But, nevertheless, I've got this user form. I've got all the different inputs named and formatted. I've got this text box here called Ht, height. Really important, you don't want to be calling things height, for example, because if you look down here in the properties window, height is already reserved for something and that's the height of this object. Right now this text box has a height of 36. You can't use these, down here these objects as names for different things in your user forms. So I've named this Ht. I've named this radius. I've named this box rho, the Greek letter, rho, R-H-O, for density. Liquid depth, I've named depth. And then the output once we press Calculate, the output here is going to be mass. And I've also got a quit button. If I wanted to I could add a reset button, too, that would unload the form and then show it. So let's go ahead and do this. Let's do the Quit button first. The Quit button is always the easiest one to code. The name on my form is TankForm. So Unload TankForm will close that down and erase anything that the user has input into the text fields. Let's now code the Calculate button. So I can click on calculate and this is where we're going to put the code. The first thing I'm going to do is Dim pi because pi is going to be new variable that we're using in these questions. And then I'm going to define pi using the WorksheetFunction.pi. Now, we've got three different pieces of this function. Remember that these are the questions for those different pieces. And also remember that the variables we're working with are Ht, Radius, rho, and depth. Now in order to calculate mass, mass is equal to the density times the volume. And what those equations calculate are the volume. So at the very end to calculate mass, we're just going to take the total volume and multiply by density. And if you don't really know where that comes from, that's completely fine. And I'm actually going to define one more variable v as a double. That's going to be the volume. And actually these are all a little bit messed up. I copied this from a previous function. So I have to make these depth and radius and the height. Now I think we're on track. So if the depth is less than or equal to the radius, then this is an equation for the volume. Otherwise, if the depth is less than or equal to the height minus the radius, then this is an equation for the volume. Otherwise, for the very top section, then this is the volume equation. And I wanted to just show you how we can extend this to a new line. So if you got a big line of code, you can always do underscore. So you just put _return and then I'm going to tab that out. So that's how you can continue it on the next line. It's kind of a useful tip. And now the output, we want to output the mass in mass, this box. We also know the density which is rho. So mass is just rho or density times the volume. So I'm just going to put here that the mass is equal to rho times volume. Now we're going to do our typical things where we put an on sheet button, we assign to a event handler when the work book is opened. We want to open this form. So I'm going to insert a module that shows TankForm. I'm going to insert a button on the spreadsheet. So here I've got a button, and this button is in the starter file, so you can just assign the macro to the run form subroutine. And I'm not going to show you how to do it, but you can assign, it's in some previous screen casts for an event handler. You can assign that to the run form sub. And I think we're ready to go, so I'm going to click on tank calculator. I'll just do something like 5 meters, a tank radius of 1 and the liquid density, let's do like 1000. For water, that's kilograms per cubic meter, and the depth of 2. And then we calculate the mass in the tank. Now, if I wanted to round this just to the, see how it's got a bunch of sig figs. Then we can adjust that using the FormatNumber function. So I've said mass equals FormatNumber rho times V. We're going to format that to the one's place. Now, when I run this, and when we calculate that. And it truncates it at the one's place. And then we can Quit. So that's just another example of how you can implement things in user forms in VBA. Thanks for watching.