Just like the InputBox function has some more advanced options, the MsgBox function also has advanced options here. Typically, what we've been using so far in part one of the course and part two of the course is this just a plain message box with a prompt. But you can add in some optional things, whenever you add in these optional things for example buttons or the title, I hardly ever use hub file and context but you could probably Google on what those mean. Whenever you have optional arguments other than the prompt, though, you need to include something on the left side of an equal sign before message box, and I'll explain what I mean by this in a few minutes with a couple examples. So we can have a prompt, we can have button codes. So this buttons here refers to these button codes down here. There's all sorts of different types of buttons that you can display. We have the default, which is OK only. We can also tailor the message box to have OKCancel, in that case we use a one for the code, and there's is also it's of others, so I'm going to kind of go through a couple of example of this. Now the buttons here can either be the text, I could write vbOKcancel. Or I can put the integer 1. Now the button code similar input box code can be combined. So if you wanted a question, but you also wanted a YesNo, then you could combine those two integers, and I could add 32 and 4 to be a YesNo message box. With buttons for yes and no, but there'd be a question mark on the message box. So I just have an example here. Again, whenever we are using something other than just a simple prompt, then you need to have an equal sign to the left of MsgBox. And you have to be assigning that. The MsgBox function will sign an output to an integer, so you have answer as an integer. This could also be any other variable that you want, but I like to use Ans a lot of times in my example. So the MsgBox function is going to have a return value, and that's kind of shown down in this chart here. When we bring up this MsgBox, the button code is 3, so if I back up one slide 3 refers to YesNoCancel, so there's going to be three buttons on there. There's going to be a yes button, a no button, and a cancel button. So if the user clicks yes on that message box, then this answer variable is going to be assigned the value of six. If the user selects no, then this answer variable is going to be assigned the value 7, and if they click Cancel, then that answer variable is going to be assigned the value of 2. So let's just go through a couple examples. The typical message box you guys have been working with is just shown here. We can message box Hello. If you want to tailor this, so here are the different buttons that are possible. I could do a vbOKCancel, so I could click on vbOKCancel. Alternatively, an vbOkCancel, I could just put a one in there. If I wanted a title here I could just say Output, and when we go through this, it's going to give you an error, because whenever you have more than just this simple prompt, the first argument, it's going to return a return value. So I need to put something out front. Even if you're not using that answer, you still have to put something out front, and you have to Dim that as an Integer. So now when we go through this, it's going to have two buttons on there, because I customized this, vbOKCancel. We got a title here, which is Output, and then we've got our prompt. And if I look down here in the locals Window the answer, so I click Cancel, the return value for the Cancel button is a 2. If I redo this and I click OK, the return value for OK is a 1. I mentioned a few moments ago that we can either write the vb, which stands for Visual Basic OKCancel, or we can use those button codes. For example, if I put a 2, a 2 corresponds to AbortRetryIgnore. So when I run through this, that's how we can tailor the buttons. Abort, Retry, Ignore. Now the return values of Abort, Retry, Ignore we can get from that table. Don't confuse the return values with the button codes. So these are the button codes. But the return values are here. So we had Abort, Retry, Ignore. Those are 3, 4, and 5. The reason we want to use this sometimes is, we want to do different things depending upon which button that user selects. So we can add in If statements. Here's a multi alternative to do different things depending upon what the user clicks. So now when I go through this, if they click Abort, that's assigned. Answer here is assigned a value of 3. So we can do something just in this example. We can display a message box, if they click Ignore, that is a return value of 5. So, that's not equal to 3 nor 4, so we can message box, you clicked ignore. Now obviously you probably wouldn't be message boxing the button that they Pressed, but you could be doing different things depending upon what they select. The last thing I wanted to show you is how you can combine these button codes. So 4 is the vbYesNo, so we're going to have a yes and a no button on the message box, so these are the button codes. 32 is for a question, so if I run through a 4 here, and the button code is 4, we get Yes, No, and you notice there's no other formatting on this message box. If I run through 32 by itself, we get a hello. You notice there's a question mark here. So that question mark is for this vbQuestion. But you notice that if you have a 0 with a question, then that's just the OK only. That's why we only have the OK button on that message box. But now if I add 32 plus 4 and get 36, there is only one unique combination that all those button codes that leads to 36. So, it can only be interpreted as a question formatted message box and the yes no buttons. And whenever I'm through this, we have a question mark and then we've the yes and no. So this is how you can customize your message boxes.