William Rosener: Hello. Hello. Welcome back. In this video, you'll learn how to create a little guessing game using Microsoft Word.
William Rosener: And Visual Basic. Let's start by taking a look at what you're going to create and then I'll walk you through the steps then
William Rosener: So take a look up here. We're going to have a three option buttons.
William Rosener: And depending on which one of these selected will be generated integers between if easiest like the between one and 10,000,005 and 20 difficult actually be generated negative numbers there.
William Rosener: So, so go ahead and I'm going to turn this off. That's my face I'm hit. I've got easy way to generate random numbers. Sure enough, I'm generating integers between one and 10 if I choose medium will actually will be getting numbers between five and 20
William Rosener: And if I choose difficult
William Rosener: We may even get an occasional negative number as we go from negative 20 negative and a positive 20 of them. Okay, so what's going to happen is we're going to generate some values here.
William Rosener: Then I'm going to come over here and if they use her interest in the correct answer. I'm going to split you the correct or incorrect.
William Rosener: At this is turned on, then two things are going to happen.
William Rosener: Then I'm going to display either crammed display correct or incorrect and either display a happy or
William Rosener: A sad face that those at this answer at this value and this value does not equal this one or displayed in correct and I'll go ahead and clear that
William Rosener: Okay, now that we don't want to do. We're going to do, let's get started here. So in the same area as you found a link to this video, you should also find an interface.
William Rosener: And then you also need to find you should find three images. Happy, sad white that JPG, and we'll be making sure to place all these in the same area. So if I take a look here.
William Rosener: I'm not going to work on assignment five be interface. Notice I've got happy, sad and white all in the same directory there.
William Rosener: OK, so the very first step. Want to do is that come over here and we're going to generate three we're going to actually insert three option buttons to do that I'll press on the Developer tab.
William Rosener: Right here it right here is option button. So I'm gonna go ahead and press on that and insert a option button. I'm not going to go ahead and right click on it, I'm gonna come up here. I'm going to call this first one PT easy
William Rosener: I'm going to give it the caption.
William Rosener: Here, easy. Now go ahead and increase the font size here just love it. So it's a little bit easier to read there and that may happen sometimes when you
William Rosener: Insert one of these option buttons, checkboxes, some of these other controls it kind of loses focus, but just kind of click right back here and you should be set.
William Rosener: Okay, once I've got one. I can copy it.
William Rosener: And paste it.
William Rosener: And now what I'm gonna do is go ahead and
William Rosener: Click on the next one I'm going to make sure I change this one to medium.
William Rosener: And I'm going to change the caption to medium.
William Rosener: And I'm gonna highlight the last one.
William Rosener: Is just too difficult.
William Rosener: And change the caption too difficult, as well.
William Rosener: Okay, so I'm insecure. We got Ott easy look and appear Ott medium and Ott difficult. Okay, now what we're going to do is go ahead and
William Rosener: Insert a checkbox and I'm gonna press right up here under design mode and the very first one under active X control is the checkbox and on this one I'm gonna call this one CH came
William Rosener: Display face.
William Rosener: Little bit. Come on down here.
William Rosener: Let's play face when
William Rosener: Verified and they'll increase the font size here just love it as well.
William Rosener: Okay and I'm going to go ahead and increase the size of that just a little bit there.
William Rosener: Okay, so I've got my three option buttons and I need to increase them do a little bit there in life. Okay. And I've also got
William Rosener: A checkbox on to over working on the interface. I'm gonna come right over here and repress down here and I need to insert an image and academics controls so interactive X control or insert the image and I'm going to call this one i n g
William Rosener: And I'm just gonna put face.
William Rosener: Okay, well, at this point, let's go ahead and get started on the generate random numbers and where these going to go. I can see I've got LBO number one.
William Rosener: And they'll be able to
William Rosener: OK, so the very first step to do is I declare a couple variables lower bound.
William Rosener: And upper bound
William Rosener: That's integer
William Rosener: Me before I forget, I'm going to come up here and put in option.
William Rosener: Explicit with I misspelled one of these. I'll get a little warning message.
William Rosener: Okay, since we're generating random numbers. The very first step you want to do is type in random minds which is going to create a new seat. Now I'm going to take a look would find out which one of these radio buttons is selected. And the first one here is Ott eating.
William Rosener: Okay if Ott easy
William Rosener: I value.
William Rosener: equals true.
William Rosener: We know it's selected which point, can I change my lower bound or specify my lower bound.
William Rosener: Upper bound is equal that
William Rosener: Else of PT medium.
William Rosener: Value.
William Rosener: equals true.
William Rosener: Then
William Rosener: Take a look at those need to be between five and 20
William Rosener: Finally, else
William Rosener: And in this case, we're actually regenerated negative numbers as well. So going from the negative 10 positive 20 and then finally we'll get the if statement there.
William Rosener: Okay, so we're now kind of specified or upper bound or lower bound. We're now ready to actually start generating the numbers and storing in there. So it's going to simply be upper bound
William Rosener: Minus my lower bound.
William Rosener: This one.
William Rosener: Is R amp D plus know lower down.
William Rosener: Okay, and what I'm trying to do is get ready for my, I know it's not quite finished up, but I need to convert this to an integer. So for now I'm ready to go there. Okay. And once I've got that one. I can copy and paste that and I'll put in them to here.
William Rosener: Okay, so I'm going to generate a random number stored and they'll be a one generate another random number and storing them to
William Rosener: And like I mentioned there. I need to convert that into integers. So right now, if I was to run them if I hit generate random numbers I'm getting 5.8 I'm getting 10 six and one I want to do is convert those two integers. So I just need to put an IoT in front of them.
William Rosener: Okay, so it's going to take all this information here and it converted into an integer and effect removing that that's the fraction there. Okay, let's go ahead and check that out.
William Rosener: It generate random numbers. I've got easy show enough. I'm generating integers between one and 10 at medium is selected.
William Rosener: Going between five and 20 and a difficult is selected. Sure enough, I'm generating positive and negative numbers all the way up to 20 of them.
William Rosener: Okay, so the next step we need to do is we're generating the random numbers correctly. We now need to check the answer.
William Rosener: And let's go ahead and take a look at what this is called
William Rosener: This in his txt guess and help y'all result somebody go ahead and let's go ahead and add some code here. I'm now under check answer and then we'll take a look is those two values are they equal
William Rosener: Is the value of LBO number one.
William Rosener: What's the value
William Rosener: I'll be on them to
William Rosener: does that equal to the value of txt yes
William Rosener: So,
William Rosener: LPL result that's a restore my answer.
William Rosener: Equals correct
William Rosener: Else. I'll be all result.
William Rosener: Equal to incorrect.
William Rosener: Okay, let's check that out. So now I can enter in a value.
William Rosener: And I can check my answer, and it will display either correct or incorrect there.
William Rosener: Okay, next step is now need to do is like, okay, if this is turned on. We now need to display their a happy or a sad face someone come back to my check answer we can right here. And I'm going to go, okay, is a CH K
William Rosener: Display face.
William Rosener: And if you're not getting this a pulldown menu that's tells me that you've got. You're not maybe a spelling mistake or it's not matching what's on your interface there.
William Rosener: OK, so the checkbox is turned on.
William Rosener: That means it's going to evaluate true now what we want to do is I want to first of all, specify where can I find these images that
William Rosener: There it is. Default file.
William Rosener: So I'm gonna say options. The default file path.
William Rosener: WD documents.
William Rosener: And I'm just going to look in the current directory
William Rosener: So again, like I mentioned, I'm going to be here. Once the fall. I'm working on. I'm just going to be looking in the current directory. And let me go ahead and
William Rosener: Get you just a little code here. If for some reason, this does not work, it should work.
William Rosener: I think every now and then. I've been on a computer lab with it did not work in this point, we could go change file open
William Rosener: Directory.
William Rosener: Peoples. And then maybe like like when I was in the computer lab or in this case, maybe upon your hard drive.
William Rosener: You would do something like that where you have, first of all, specify ok change to your see on your heart on your C drive the director, God has put up there and I'm going to comment that out. I don't actually need that here today.
William Rosener: So I'm going to go options default file path. I'm going to be looking in the current directory not going to say IMAGE FACE section, we better come back and I don't think we gave that a name yet.
William Rosener: So let's take a look here. I'm going to right click on properties excited i n g face. So that is where we're going to store this picture.
William Rosener: So I'm going to go home. I am G face.
William Rosener: Picture.
William Rosener: Here and we're going to put in happy jpg
William Rosener: And now I need to in
William Rosener: That if statement here. So this summer start this end and this sets on I noticed by cracked
William Rosener: I'm now going to take a look. Is that checkbox on if so I'm going to display the first of all, specify hey look in the current directory for a picture called Happy Dot jpg and load that image face that picture.
William Rosener: Okay. And then what I'm gonna do is maybe I can come along here and save just a little time here. I'm gonna grab this card right here, who in a paste it.
William Rosener: Actually delete that line right they're
William Rosener: Not going to take a look
William Rosener: Is the checkbox selected. I've got an incorrect. So what I need to do something to change this to sad.
William Rosener: Okay, we're should be now ready to check this out. I'm going to go ahead and close it.
William Rosener: I'm going to put in a correct answer. So I've got my display box on on to put an eight here it check answer. And I'm going to get correct and a happy face. And if I was to put in an incorrect answer.
William Rosener: I would get incorrect and the South. So check this out. Go ahead and work on the clear button that should be proud of all
William Rosener: The clear it's going to be just a little tricky here. The first three will be really straightforward her
William Rosener: LBO number one.
William Rosener: Was an Australian I'll be on them to
William Rosener: People's an Australian txt guess
William Rosener: Was an Australian in LB our results.
William Rosener: So actually restore there.
William Rosener: So 1234 does just regular
William Rosener: A little clear button, it's going to clear. Well, how do we get rid of this some face here. And to do that.
William Rosener: I'm going to come along. I can actually place it at the beginning, the end of the place in here. Now I want to go ahead and grab that line of code right up here just to make sure I'm in the current directory
William Rosener: And I'm even read both of these lines here.
William Rosener: So first step is just simply say, okay, look in the current directory
William Rosener: Now, rather than being happy or sad. There's an image there called white Dot jpg
William Rosener: And then said, check this out.
William Rosener: So maybe I'll start off from scratch here. But tell me, hit the clear button it's working. So kind of starting from scratch.
William Rosener: A good easy to generate random random numbers I could enter value. I can check the answer correct or incorrect if display face when verified is on. Now it's going to do. Correct. And a happy face.
William Rosener: Or incorrect. The sad face and then the clear is going to go ahead and clear these four values and the face well find this video you'll learn how to create a little guessing game using Microsoft Word and Visual Basic our kitchen next video. Thanks. Bye.