William Rosener: Hello, Dr. Bill, welcome back. And this video you'll learn how to develop the money calculator using BBA Visual Basic for the applications.
William Rosener: In particular, will be using Microsoft Word. Let's start by taking a quick look at the interface run through it and then we're going to recreate this whole thing from scratch.
William Rosener: So on a lot of user to endurance and nickels and pennies. Some dimes.
William Rosener: Quarters and $1 bills and then when I saw the calculate two things are going to happen. I'm going to display the total
William Rosener: Then what do a string concatenation that says this case by pennies nickels four times etc is equal to $7 and 10 cents. And finally, we'll go ahead and press create a clear button to clear that up.
William Rosener: Okay, now that we know what we're doing now let's go ahead and get started here. So the very first everyone do is press on the Start icon. I'm going to press on Microsoft Word.
William Rosener: And I'm just going to choose great a blank document, though, look at the very top, we have it saved money calculator.
William Rosener: And then go ahead and put your name.
William Rosener: And I'll go ahead and increase the font size this a little bit and maybe even kind of reduce the space in here.
William Rosener: And sang call, and I believe that was centered something that over there.
William Rosener: Okay, now take a look at the interface here. I'm gonna challenge you a little bit. I'm just going to do dimes quarters $1 bills and told us, but I'm gonna let you also add nickels and pennies.
William Rosener: And if you really want to get out like $5 bills etc $10 bills. But definitely, I'm gonna have you do pennies and nickels, but I'm just going to do
William Rosener: These three here. So I'm gonna need 12345 rows and three columns, but you actually need seven or more. Okay, let's come back here. I'm going to come over here to insert and we go to the table and in my case here, I'm going to do a three by five.
William Rosener: We come right up here and I'm going to type in dimes. And again, I'ma let you do that pennies and nickels and years, and I'm typing Porter's
William Rosener: I'll type in $1 bill.
William Rosener: OK. And now what I need to do is get my I'm gonna start importing some text boxes. So I need to get them my case the Developer tab is artificial. Number one through one more time, how to get that
William Rosener: Displayed some press on file momentarily turn mine off and then I'll walk through the steps again airless lower
William Rosener: OK, so the very first section. Want to do is get your Developer tab visible. And to do that, you're in WordPress on file good options press on customized ribbon. Select the Developer tab and then press okay
William Rosener: Now I've got the Developer tab visible and I can insert some text boxes. So the first step. I'm gonna do is position my cursor where I want the text box. I'm gonna come right up here. I'm going to choose a be a vertical bar text box.
William Rosener: Active X controller.
William Rosener: I'm not going to right click on it, I'm gonna go to properties. I'm gonna call this one txt
William Rosener: And I'm gonna go ahead and increase the font size.
William Rosener: And maybe I'll go ahead and stretch that out a little bit.
William Rosener: And before I forget.
William Rosener: When you're finished with this. You want to make sure you save it as a
William Rosener: Macro enabled document. I'm just gonna let me just come right up here really quickly. I'm gonna go to File, Save As I'm, I'm going to bother with saving mine.
William Rosener: But you're going to want to make sure that you save this as a word macro enabled document if you just saved it as a Microsoft Word document, it's not going to save your code to be Visual Basic so make sure you save it as a word macro enabled document them.
William Rosener: Okay, so we've got one for red txt dimes. I'm gonna go ahead and copy that.
William Rosener: Paste it. Paste it. I'm not going to come along and highlight this one, and I'll change this one to say quarters.
William Rosener: And I'm gonna highlight this one and have it say dollars.
William Rosener: So I've got txt dimes txt quarters and txt dollars.
William Rosener: Okay. And next thing I need to do is I'm going to put the total here.
William Rosener: And I need to. I don't want the user actually entering data in for tell it all that's going to be computed automatically. So I don't want to text box here, instead, what I want is a label summer press on.
William Rosener: The activity under active X controls, just this little a, sort of a label and I'm going to call this saying, give us the name. I'll be on
William Rosener: Total
William Rosener: And I'm gonna go ahead and delete.
William Rosener: The caption.
William Rosener: Now what I want to do is a couple things. I'm going to increase the font size of the team. But I also want to
William Rosener: Go ahead and have this because right now. It doesn't even appear so let's go ahead and change.
William Rosener: The border change the border color.
William Rosener: So I'll start off with the back the back color.
William Rosener: shade of blue and I'm gonna go ahead and change the Border style to single and it's kind of right here. Maybe a little bit darker.
William Rosener: Okay.
William Rosener: And let me one more time. I think I changed the font there.
William Rosener: Okay.
William Rosener: Without any text in there. It's kind of hard to tell if I did or not. Okay. Now take a look here. I want to take all of this information and merge those cells.
William Rosener: So I'm gonna highlight this information right here right click on it, Murcia cells. Then I'm going to take the bottom information. The bottom row. These three cells, right click and merge those cells.
William Rosener: And now what I want to do is insert another label down here right up here. Choose on label and in this case, I'm going to call this one LPL answer.
William Rosener: And I'm going to go ahead and delete.
William Rosener: The caption. I'm gonna go ahead and increase the font size.
William Rosener: And write that out.
William Rosener: And let's see what's if there's anything else. I have to do it looks like Word Wrap is set to true. I think everything is going to be ready to go. So I've got three my case here, three text boxes, you're going to have at least five, then I've got a couple of labels to display some output.
William Rosener: Okay, now we're going to come up here and we're insert a couple of command buttons. So I'm gonna come right here and under active X control I'm insert a command button.
William Rosener: And I'm going to call this one, C and D calculate
William Rosener: And then going to change the caption to say calculate
William Rosener: increase the font size.
William Rosener: Okay. And once you've got one. I'm just gonna go ahead and copy
William Rosener: And paste
William Rosener: That over here.
William Rosener: Copy.
William Rosener: Paste. At this point, I'm gonna go ahead and highlight this command button. We come up here.
William Rosener: We call this CMT clear
William Rosener: And the caption on the button will say, clear as well.
William Rosener: If you want, we could do for little space there. And you could also possibly increase a high to some of these roads, if you want.
William Rosener: Okay, there we go. So we've got our interface up and running there. We're now ready to start working on the code there.
William Rosener: So what's going to happen is we're going to take this information, find the total and display it into this case, it's called he'll be all total
William Rosener: So I'm gonna go ahead and double click on the command button calculate
William Rosener: And we'll get started here. So that's going to take me right into Visual Basic for the applications. So again, I hope, like from the first 50 realized that
William Rosener: I'm in the design mode. So when I press Sonic command button in design mode, it goes to the source code when I exit the design mode when I press Command, but it actually execute the code there. So since I'm on the design mode.
William Rosener: When I press on the calculate button, it's going to take me to BBA right can begin entering some code here.
William Rosener: So I'm gonna say LBO total is equal to, well, I can simply. First of all, I can take the dollars.
William Rosener: And I could I could probably I'll tell you what did this incorrectly first and then we'll go ahead and start making some changes here.
William Rosener: Okay, so the very first, this isn't working. This isn't righteous. We'll go ahead and take a look at it. So I'm just going to take the dollars the quarters of Dimes add them all up and put them in total. Okay. So if I was to run this right now, if I was to put in some numbers here.
William Rosener: And if I was to hit calculate all it's doing right now is a string concatenation. It's taking these various strings and concatenate them up there.
William Rosener: That maybe I should have actually probably made sense. If I had reverse the order of these since I got dimes at the top. Had I done dimes first
William Rosener: It really doesn't matter here.
William Rosener: The string concatenation someone take dimes quarters and dollars. And so now when I run that I'm getting 321 let's see number 334 and five.
William Rosener: And so what it's doing as a string concatenation is taken the strengths and adding them up. Okay. As we saw in the first video or they need to do is first of all, can find the value
William Rosener: more work to do that, we can just simply add them up. We got to convert them to a common currency.
William Rosener: Or a common denominator, before we add them up there.
William Rosener: Okay, so now if I run this.
William Rosener: Okay, it's at least adding numbers. Well,
William Rosener: Three, four, and five does not equal $12 so okay so the dollars is fine. We can simply add those, but the quarters.
William Rosener: If I've got four quarters. Well that's $1 so we're in it. And then if I've got the 10 dimes. That's another dollar, they're not to liberty be done, just put this at 10 here. So at this point we would have five, six and $7. So let's go back to our code and we'll start working on that.
William Rosener: Okay, so the dimes. I'm gonna have to do is divide that by 10. So if I've got 10 dimes divided by 10 that's going to give me $1
William Rosener: And what you're going to find is with operator precedence division is going to have priority over the addition. But if you wanted to, you could place a parentheses around all this but it's absolutely. It's not necessary.
William Rosener: Okay. And then another thing. What you may want to do is I can, I can begin to see that this is going to go off the screen. So I'm going to go ahead and put an underscore and put a
William Rosener: Put a space before space after the underscore, and we cannot continue this command on the next line and then I'm going to take
William Rosener: Quarters, and I'm going to divide that by four.
William Rosener: And if I want just to be kind of consistent with what I've got going on earlier, I can go ahead and put this in parentheses and maybe I'll even go ahead and tab. This over
William Rosener: And I'm going to go ahead and continue this on the next line. So we're pressing underscore, and that's going to say continue on the next slide there.
William Rosener: So now what's going to happen is we're going to take the dimes divided by 10 so if we had 10 times
William Rosener: 10 divided by 10 is one we had four quarters for an add another dollar plus we could add dollars when I have to do anything with dollars it's already in the in the correct format their currency, though.
William Rosener: Okay, let's go ahead and run that I'm gonna go ahead and design mode and hit calculate and sure enough, I've got 10 dimes four quarters $5 I'm getting seven there.
William Rosener: What would be nice to see the dollar sign in front of the seven. So let's go ahead and format that is currency something come right back here. So I have convert up done than necessary addition there. I'm not going to say LPL total
William Rosener: Is equal to the format it
William Rosener: I'll be out. Oh.
William Rosener: And then double quotes here. I'm going to type in currency, make sure you have stopped currency right there.
William Rosener: And what's going to do is it's going to take. It's going to format. What's an LBO total as currency and then write it right back on top of itself. So I'm going to take it formatted its currency and place it in the exact same area there.
William Rosener: Okay, so now if I press on the Catholic command button. I'm getting some the dollar sign accepted there. So if I was to put in 11
William Rosener: I would get $7 and 10 cents. Okay, the next step we need to do is work on this string concatenation.
William Rosener: And let's get started on that. So I'm going to go ahead and double click on the calculate button.
William Rosener: And I'm gonna come right up here and we'll kind of slowly build this and I'm gonna go ahead, say, help me.
William Rosener: Answer is equal to
William Rosener: 60
William Rosener: Times.
William Rosener: So it's going to take the information in there that say, well, let me go ahead and just I'm gonna I'll be making a kind of a few mistakes Arab
William Rosener: Just to kind of slowly build this erupts. Let's go. Go ahead and put the txt dimes like that. So now what's going to happen is when I run on it, run it.
William Rosener: It's going to put loving and the dimes. Notice how this information is kind of jam together and I want to space here. So I'm going to go ahead and come right back here.
William Rosener: I'm going to put a space for this.
William Rosener: Now I'm actually going to go ahead and put a comma and a space after it. So now I can begin to get ready for the next information there.
William Rosener: Okay, and what I'm not going to do is work with quarters. And again, I'm going to put this if you had a small font here you could continue on the same line, but I'm going to put an underscore
William Rosener: And a space. And that's going to say this instructions continued on the next slide. Typically instruction has that occupies one line there. But if I wanted to spend more than one line I needed underscore there.
William Rosener: OK, now let's come up here and I'm a type a txt quarters.
William Rosener: contaminated with just like I did here quarters.
William Rosener: And space. Let's see what we've got here so far.
William Rosener: So I'm going to press on the Design Mode calculate. So I've got loving dimes four quarters and now I'm going to put in the $1 bills.
William Rosener: So to continue this on, we put an ampersand another string concatenation the underscore saying this continued on the next slide. And then I'm gonna take and txt dollars.
William Rosener: And up with dollars there.
William Rosener: And then I'm gonna have an equal sign and let me go ahead and close it right there.
William Rosener: And we still got just a little more work here.
William Rosener: Okay, so now when I press calculate. I'm gonna say love and dimes four quarters, we could put the word. And if we wanted to and $5 is equal to our belt.
William Rosener: So what I could have done was put in and
William Rosener: Actually could have ended up here.
William Rosener: And so I'm gonna have like four quarters and the morning, say like $5. Okay. The last step, I need to do here is actually concatenate LDL total
William Rosener: Yeah, let's go ahead and put a period at the end.
William Rosener: Okay, so if it's in double quotes that is a static string that's always going to say times space times, comma, this case, it's a variable and it's going to possibly change depending on the data that we have entered. Let's go ahead and run through this
William Rosener: I'm not going to press the design mode here press on calculate and I'm getting loving dimes four quarters and $5 is equal to $7 and 10 cents. And this is all looking up. Perfect. Terrible. So last step here is our clear button.
William Rosener: Okay, that's going to be pretty easy. We're just going to take all these things dimes.
William Rosener: Quarters
William Rosener: And help you answer and I'll be able total
William Rosener: All equal to the string.
William Rosener: And we'll be getting into at some point I probably should talk about created use an option explicitly. Let me go ahead and run this quick here.
William Rosener: And clear. So that's all working here. Let me go ahead and run through Option Explicit I always highly recommend that you turn that on.
William Rosener: So at the very top, I could come right up here and type in Option Explicit
William Rosener: And now I've got two five, possibly, but definitely when we get into more with variables there if I misspelled a variable name, it's going to tell me about it.
William Rosener: And I'm thinking, even if I missed all times maybe putting an extra D on it. Now when I run my a clear button. It should give me a compile air variable not defines like wow ok I missed all times.
William Rosener: Okay. And again, maybe like last time there. Go ahead and at the very top here you could put the assignments when be and when another little, little quote there are simple quote and put your name.
William Rosener: That way if you print it out. You can make sure you're printing out your copy and not someone else's then maybe you even want some other information up there. The course the semester, except for them.
William Rosener: So let's take a look at this one more time here. Whoops.
William Rosener: So here is our interface, I can now allow the user to enter dimes quarters $1 bills and when I hit the calculate can do two things display it. So let me get make sure I can put this in some nice increments here.
William Rosener: Okay so $2 four quarters in 20 times is going to equal $5. So sure enough, I'm computing the total and I'm doing a string concatenation. If you wanted that all in one line. You could either decrease the font size or in my case here, I could stretch this out a little bit.
William Rosener: Okay, so now if I press on that it clear, they'd be interested. Some more values.
William Rosener: The calculated. I can see that's all up here and on one line though. Okay, well, then it's going to conclude this video again make sure when you save it, you save it as a macro enabled document I guess next video. Thanks.