William Rosener: Hello. Hello. Welcome back. In this video, you'll learn how to create a conversion calculator using BBA Visual Basic for the applications in particular will be using Microsoft or
William Rosener: Let's start off by taking a look at what you learn how to create and then I'll walk you through recreating this yourself.
William Rosener: So the very first step one do is allow the user to enter and feet. Let's say it's a 15 feet and six inches and I had to calculate
William Rosener: On to do several things around display the total number of food, feed and we'd be 15 and a half feet 5.17 yards on display the meters.
William Rosener: And then also, at the bottom here, we'll do a string concatenation taking all this information and display it in one label there that wants to go ahead and create a clear button. Now that we know what we're gonna do. Let's get started.
William Rosener: So in the same area as you found a link to this video, you should also find this we call it the interface which is all the labels, the text boxes and so forth there just to save a little time so you don't have to recreate this whole thing from scratch.
William Rosener: But the maybe the first step we should do is so let's go ahead and take a look at what these labels are called and I'm gonna go to properties.
William Rosener: And I could see this is called txt feed and this is txt inches. So again, if it's a text box that allows us to enter in information.
William Rosener: Probably on this call, it's going to start with txt. These are going to be labels. We don't want the user enter an information here. So this is LBO feet.
William Rosener: This is going to be LBO yards. Help me. Oh, meters and LBO answer. Okay, now that we know what those particular text boxes and labels are called we can get into the BBA and now we know how to read that data and right to it as well.
William Rosener: Okay, so I'm gonna go ahead and double click on calculate button.
William Rosener: And that's going to take me to the sub routine here.
William Rosener: So I've got when I click on this particular button, it's going to execute the code between the private sub and the inside and the very first step. I'm gonna do is let's do I'm going to declare some variables. So I'm going to declare feet as an integer.
William Rosener: And declare inches as an editor.
William Rosener: I'm gonna come up here and put Option Explicit on
William Rosener: And I've actually explicitly turned on, then I need to declare the variables. In this case, I'm gonna have feet and inches.
William Rosener: And it's going to help if I misspelled words here later on maybe I'll purposely make us bone steak and my have an Option Explicit it's going to help solve kind of diagnosis of track that problem down so feed is simply equal to
William Rosener: The value in txt feed.
William Rosener: And inches because simply equal to the value and txt inches.
William Rosener: So, so far all up. We've done
William Rosener: Is I've taken the information and this text box information this text box. And I've written them to some variables here so I'll called one feed.
William Rosener: And one's called inches. I took that information places he took this information and place it in inches. We can now go ahead and begin working on feet.
William Rosener: And so again, if I take a look here at the interface. If I was to right click on that and go to properties, actually, here's the one I'm looking at LPL feet. So I'm now going to be trying to create the answer to put an LBO feed.
William Rosener: Okay, help your feet. It's going to be simply the feet, plus inches divided by 12
William Rosener: And the priority of this is going to say that division takes place before edition. But if you want to make sure, go ahead and just simply put parentheses around that kind of maybe helps clarify. Okay. Yes, I'm going to take the inches divided by 12 add that to the feet.
William Rosener: And let's go ahead and just take a look at see what we've got here so far. So I'll put my I'll go ahead and first of all exit the design moon put
William Rosener: I'll put the six years. I did earlier and I'm gonna hit calculate and that's looking great. I'll tell you what, let's go ahead and change this from six to seven.
William Rosener: And now all of a sudden, I'm getting a lot of decimal points. Let me go ahead and show you how to take care of that. So get a little bit more consistent luck.
William Rosener: So a couple ways here, but the bottom line. Those are gonna say, I'm gonna take what was an LBO feed and I was simply format that
William Rosener: And one way to do that is to use fixed. This is going to put two decimal places there. So I'm going to take what's an LDL feed format. It has fixed and then place it right back on top of itself.
William Rosener: So now if I was to execute this I'm going to get the two decimal points. What if I want one decimal point or three. Let me go ahead and show you how to do that.
William Rosener: So what I can do is just simply comment this one out.
William Rosener: Of your feet is equal to a format.
William Rosener: Of your feet.
William Rosener: Now, what I can do is put some dollars a pound signs.
William Rosener: And then I'm going to put the start off with one, zero.
William Rosener: OK. So again, I'm going to format. I'll be I'll feed. Here's the format. The big thing here is a decimal point and one notices on the only one decimal point and then display that and I'll be I'll feed.
William Rosener: Sudden now when I go ahead and calculate, it's going to put 15.6 effect. I'm rounding that if I want to two decimal points.
William Rosener: I can point to
William Rosener: It to calculate
William Rosener: And see the 515 point five aid. I wanted three, no problem. I can just simply put three here.
William Rosener: Take a look at that.
William Rosener: And now I've got three decimal points. I'll probably go back with the two. Okay, so now. So now we can start working on yards and maybe just every now and then I should probably take a look here. And that's simply called LPL yards. That's one of the display the information there.
William Rosener: So I'm actually going to go ahead and reverse this just to kind of keep them all the same here. I'm going to go ahead and use the fixed format with the two decimal points.
William Rosener: And now for yards. I'm a simple put yards.
William Rosener: Is equal to
William Rosener: Feed plus inches, just like I did earlier divided by 12
William Rosener: And if I wanted
William Rosener: I can place this in parentheses, just like I did earlier. So now what I want to do is everything right now is in feet so simply take all of this information.
William Rosener: And divided by three.
William Rosener: Okay. So I'm now going to take up the feet. The inches. I now have everything in feed divided by three and display it in yards and it will. I'll just go ahead and while I'm right here. I'm just going to go ahead and also format this
William Rosener: With two decimal points.
William Rosener: There's some type of this. I'm almost wondering if I call this yard or yard. Somebody come right back here.
William Rosener: It's the floral LPL yards. Okay, so I need to make sure that I've called this yards yards and yards.
William Rosener: Okay, so let me go ahead and run this at the calculate and sure enough, I'm getting 5.19 yards.
William Rosener: Okay, next one is going to be a meters.
William Rosener: You know, come right down here. I'm gonna say LPL meters is equal to, and I've got a formula right here that told me what it was.
William Rosener: from inches to meet or something. Go ahead and I use that in order to need to do is multiply inches times 0.254 to get it in meters. So I need everything in inches. So now I'm going to take a feat times 12 to get that into inches plus the inches and I need to take all of this.
William Rosener: And
William Rosener: Multiply.
William Rosener: 0.02 by four to convert that into a meters.
William Rosener: And need one more for to see them.
William Rosener: Okay, and just like I did earlier. I'm going to go ahead and take this and change it to meters.
William Rosener: Just to make sure everything
William Rosener: Is with two decimal points. So in this case, I had a formula I simply take inches times 0.0254 I'm going to get meters. So in this case I converted everything into inches particular feet times 12 plus inches.
William Rosener: OK, now I'm going to calculate and display that and I think
William Rosener: We just check here. I think everything's looking perfect. Okay, now what we need to do is work on this bottom where we actually display take all this data and display it in a single label.
William Rosener: Okay.
William Rosener: Right click on this and it's called LP answer.
William Rosener: Somebody say help me answer.
William Rosener: Is equal to txt fields.
William Rosener: With
William Rosener: Feet.
William Rosener: So let's just go ahead and break this up and maybe what I could do is come over
William Rosener: I'm actually going to put some values in here. This was the work in one. So it's going to say 12 feet and four inches is equal to
William Rosener: So right now.
William Rosener: It's just going to say 15 feet, and I'm going to take the inches.
William Rosener: So I got 15 feet in
William Rosener: And if I want. I'm going to go ahead and and maybe break this up and put it on its own lawn. So we put an ampersand and I'm gonna put a space underscore and a space and now continues on the next one and I'ma say txt inches.
William Rosener: Inches is equal to
William Rosener: And now what I want to do is I want to put I get a hard return in there. And that's simply
William Rosener: We're here at the house key value the character for 13 which is a hard return. So that's going to actually advanced the cursor down to the next slide, but before doing that. Let's go ahead and check it out.
William Rosener: Let me go ahead, press on the design mode at calculate and I can now see I've got 15 feet and six inches. So again, depending on whatever value. I've got up here if I've got 14 and five.
William Rosener: It's going to say 14 feet and five inches is equal to. And now I want to simply display this information and feed yards and meters.
William Rosener: Okay, so I'm gonna go ahead and break this up. I'm going to do a string concatenation.
William Rosener: And then I'm gonna put an underscore since I'm starting to run out of room and put a space.
William Rosener: And now I actually wanted some spaces before that. So notice how this is indented over a little bit here.
William Rosener: Somebody go ahead and
William Rosener: Put a
William Rosener: Few spaces here and I think here in a second. Hopefully the sub disappears here and then I'm going to put string concatenation LB out feet.
William Rosener: Feet.
William Rosener: Let me just
William Rosener: There we go. Not sure why that was in red. OK. So now what's going to happen is it's going to display the string and then on the next slide. I'm gonna have a few spaces and it's gonna say like five feet so table. Let's go ahead and write it
William Rosener: Here. OK, so now I can see it's displaying 14.42 feet it's going right back to the code.
William Rosener: Okay.
William Rosener: Redo a string, string concatenation as the person, but I will continue on the next
William Rosener: Few spaces.
William Rosener: Yards.
William Rosener: And I table while I'm here, I'm just going to go and finish this all up another string concatenation. And again, if I wanted to, I could put this all in the same one gonna break it up so I need that underscore at the end.
William Rosener: Meters.
William Rosener: And meters.
William Rosener: OK, notice the last one does not have the underscore at the end. Only if you're going to continue the command on to another line which need that underscore
William Rosener: Okay, so we're ready to check this out here.
William Rosener: I calculate. Oops, I forgot my car 13 there.
William Rosener: So here I've got it. I now want to come right here.
William Rosener: somewhere within here on a put a car.
William Rosener: Or team that's going to be added to the next line and the same thing here.
William Rosener: See HR
William Rosener: 14, make sure you get this first one because it's up I'm going to do a string concatenation of the hard return and then another string concatenation. Let's go ahead and take a look at that.
William Rosener: And the design mode. And there we go. So let me go ahead and put in
William Rosener: And six just to make sure. Here it's a 15.5 everything's looking good. So I'm computing the three amounts and then doing a string concatenation taken all this data and this planet and one label 15 feet and six inches is equal to
William Rosener: It didn't have feet 13.17 yards and 4.72 meters. Okay, finally, the last step here is the clear button.
William Rosener: There, we're just going to simply
William Rosener: Take all these feet.
William Rosener: One string.
William Rosener: With our
William Rosener: Feet.
William Rosener: Yards.
William Rosener: Meters.
William Rosener: And copy. Oh, answer.
William Rosener: That
William Rosener: Take a look at the clear button. And sure enough, all the data is a clear there.
William Rosener: Okay, one last thing here. Maybe I went through that Option Explicit one last time here. If I wish to make a spelling mistake and that is advantage of
William Rosener: Having that Option Explicit turned on the table. Maybe I'll turn it off your first of all, and then I'm going to go ahead and change this to. I'm going to put to misspell. I'm going to put
William Rosener: I'll tell you what, let me misspell
William Rosener: Inches
William Rosener: I'm not sure I just felt that by that. Again, I missed about inches on purpose here. So now let's go ahead and run that I'm gonna hit the design mode hit calculate and what is happening is it should be 15.5 but it's simply
William Rosener: Going okay the value of inches misspelled is zero. So this if I get this one up here. It's got the correct value. But this one has incorrect value because it doesn't know what
William Rosener: Inches spelled this right is equal to. So just because of the value zero. But now let's go ahead and turn this Option Explicit on. Now let's go ahead and run the code.
William Rosener: Again I compile a variable not define it's like
William Rosener: This misspelled inches. Somebody come along and put the here.
William Rosener: And now when I run it, it's working again.
William Rosener: And if you want it to like we've done some of those other videos if you wanted to maybe come up here to the very top and you could put some documentation.
William Rosener: Nothing else may put your name. You put the course semester, etc. They're just so when you print it off, you kind of, sometimes it's nice to have the source code match.
William Rosener: And you would possibly print this out from Microsoft Word. You didn't print out the source code, possibly stapled together just to help you down the road there. No, thank you. I think this video please get your little conversion calculator working and I'll catch the next video. Thanks. Bye.