William Rosener: Perfect. Well, welcome back. In this video, you'll be introduced to option buttons, checkboxes generating random numbers and swapping numbers.
William Rosener: Let's start to take a look at what you want to create and we'll go ahead and walk through the steps here. So the very top or have some option buttons so I can check female we have that text appear or mail and I'm gonna come along and I can either bone.
William Rosener: Or underline working actually do both.
William Rosener: Then we're going to go ahead and press create a button called generate random numbers, it's going to generate that two numbers between one and 10
William Rosener: The user with invalid. Enter a guess we can hit the check answer and these two numbers equal this number where display cracked
William Rosener: The users to enter some other value, you would say incorrect and within credit clear button. Finally, the last step is we're just going to simply walk you through how to take information in one cell, or in this case the five and the 10 and swap those numbers back and forth.
William Rosener: Okay, now that you know what we're to do. Let's get started here. So in the same area as you found a link to this video, you should also find this interface.
William Rosener: And I'm going to give you most of it here, but since this is the first time we're going to be using option buttons and checkboxes. I'll let you go ahead and
William Rosener: Insert these yourself him. So I've got my Developer tab visible and if you're if you're resistant. You're just simply come over here to file a press on options customize ribbon and make sure your Developer tab is visible there.
William Rosener: Okay, so I'm gonna press on the Developer tab. I'm gonna put my cursor where I want my command. My option buttons and we'll put up female and male there. So I'm going to press right here.
William Rosener: In here is the option button under active X control option button right there that's going to create an option. I'm not going to go ahead and right click on it, we go to properties.
William Rosener: And I'm going to call this one. Oh, PT
William Rosener: Female
William Rosener: And then I'm gonna go ahead and give this the caption.
William Rosener: You know, and while I'm here. Let me go and increase the font size a little bit here.
William Rosener: About go from eight to 14 there.
William Rosener: Okay, so I did three things with this one Ott I gave it the name hope et male I gave it the caption. Female. Female and I increase the font size. Once you get one done if you want you to simply select that one and paste
William Rosener: Okay and this one I'm going to go ahead and click on it and I'm going to change the name to PT abbreviation for an option button male. I'm going to go ahead and give this the caption.
William Rosener: Veil, and I've already got the font size center. Okay, so I've got the two option buttons, you're going to find these are always mutually exclusive.
William Rosener: I've got 10 option bonds, only one can be selected next time to do is insert some checkboxes, and to do them to come right up here and write 100 active, active X control the very first one, a checkbox, then
William Rosener: I'm gonna go ahead and give this a different name on the call this one CH K in that needs to say bold CH a ball. So I'm going to give it the caption of what appears on the interface. And then I'm going to go ahead and also increase the font size on this as well.
William Rosener: Okay, once you get one done, we could copy it and paste and then I could come right up here, it changes from bold.
William Rosener: Underline
William Rosener: Whoops. Let me get back there and make sure I'm gonna give it the caption, the new line.
William Rosener: And it's already got the correct font size there. Okay, so I've created a couple option buttons. A couple of checkboxes. And again, these are not mutually exclusive. I can actually have both of these turned on. Okay, well let's go ahead and see what this thing is called
William Rosener: And it is LPL answer. So I'm gonna go ahead and start over here with a female with double click on that and let me drag this here into the screen recording window, and I'm going to do is I'm going to say, yeah.
William Rosener: Female what selected, I'm gonna say LPL answer is equal to female
William Rosener: Was selected.
William Rosener: Okay, pretty straightforward. They're good. And then I'm going to go ahead and double click on mail. I can see if this is correct. What I'm going to do is I'm going to go ahead and say,
William Rosener: He'll be out answer.
William Rosener: Back here.
William Rosener: And I'm a change this to
William Rosener: Mail was selected. So let me go ahead and close that at this point. If I run it, I can choose female or male, and you can see I can, as I select that.
William Rosener: This particular caption is changing here. Okay, next step we're going to do is I go ahead and work with bald and underline, I'm a double click on ball whoops LM looks like I've got the use of renamed and correctly, you're gonna go ahead and
William Rosener: Watch how I did that button. This one needs to be CH K
William Rosener: Bold and this one needs to be CH.
William Rosener: And most likely, when I did the copy and paste
William Rosener: I thought I was copying and I probably pasted the wrong one there. So CH K bone and see HK another one. Okay, so I'm gonna go ahead and double click on the top one.
William Rosener: And sure enough, I can see let me actually go ahead and delete them. I can see where my cursor.
William Rosener: Well, it's right in here, CH cabled click OK. And this one, I'm just going to go ahead and type of segment we're going to see HK bald.
William Rosener: Guy that's going to tell me is this one checked. That is true. That's a Boolean right there that's set to true. Then I'm gonna say LBO cancer type font.
William Rosener: Bold
William Rosener: equals true. And again, I could press the Tab key right here to finish that off.
William Rosener: Else.
William Rosener: Would say LBO cancer.
William Rosener: I font and if you're not getting this right here that tells me that you have. Second, see I got font and if I could.
William Rosener: If I was to miss misspelled that
William Rosener: You can see I'm not getting that pulldown menu.
William Rosener: Okay, so I've got font.
William Rosener: Equals this case faults end. Yes. Okay, so at the checkbox is turned on. It's true. I'm gonna make this bold else I'm going to make that false by segment defaults. Okay, go ahead and run it and if I press on it. I can see I can toggle that between kind of regular and bold font.
William Rosener: Okay, now for the underlined and I can see right here, CH came under one will take a look and see HK underlined.
William Rosener: Value.
William Rosener: Is that set to true effect is it selected. If so, I'm gonna say LPL
William Rosener: He answer Todd font.
William Rosener: On your line.
William Rosener: Is equal to true.
William Rosener: Else. I'll be I'll answer that font underline. And again, just press the Tab key there equals false and in the statement them. Okay, we're ready to check that.
William Rosener: Go ahead and close it exit the design mode and it's working beautifully. So again, these are not mutually exclusive. I can have none of them selected. I could have one selected where I could actually have both of them selected them.
William Rosener: Okay. That completes kind of this top little third now moving on down here. We're going to go ahead and generate a couple random numbers. That's going to be the very first step. And let's see what these labels are called so I'm going to right click on that. This is LBO number one.
William Rosener: And I'll be on them, too. So we're going to generate some random numbers store one, and I'll be I'll know on another random number in LBO number two.
William Rosener: Okay, somebody to go ahead and double click on
William Rosener: generate random numbers and that's going to take me right here to my code.
William Rosener: Okay, the very first step I want to do is type in randomized and that's going to make sure I'm getting a new seat. I'm always getting random numbers, then I'm going to do is I'm gonna use a function called our end in our end. Let me just show you here what happens, some
William Rosener: r&d is going to
William Rosener: Documentation here.
William Rosener: Okay, R amp D is going to return a decimal value greater than or equal to zero and less than one. So let me just go ahead and I'm just going to place. What's an R amp D and LB on them on. Eventually, we might be generated integers between one and 10 so we've got a little work here.
William Rosener: So I'm gonna go ahead and not run this.
William Rosener: And I can see I'm getting point 28361 here. I'm getting 6.3 point eight 9.839 etc there so I'm getting two random numbers. Every time I press on this, we want to do is generate random numbers between one and 10
William Rosener: And the formula is going to be upper bound
William Rosener: Minus lower bound.
William Rosener: Plus one.
William Rosener: r&d plus lower down.
William Rosener: Okay. So that's the formula. We're going to be using here. So let's assume we want to generate integers between one and 10
William Rosener: So I'm going to take, but upper bound 10 minus a lower bound, one plus one.
William Rosener: Is our NDA plus
William Rosener: One. And initially, you're going to go, why didn't you just put 10 here. And what you're going to find is
William Rosener: A few months from now, and you look at your code. If you get this formula, you're going to okay I'm putting 10 minus one plus one.
William Rosener: And also, if I start generating let's assume I want to generate integers between a negative five, or negative and a positive value or maybe I want to generate integers between five and 20 which point I would just simply be putting in
William Rosener: This case it would be 20 being upper bound by lower bound would be fine.
William Rosener: And then would help them make more sense down the road them. Okay, let's go ahead and run this guy. One last little step to do here. But that's getting we're getting closer.
William Rosener: So if I generate random numbers now.
William Rosener: I can see I'm getting 8.81 5.7 etc. But I want to do is generate integers. So I need to do is put a little high and tea here.
William Rosener: And make sure I put apprentice at the end. So I'm going to take whatever value I have created here take just the integer portion of that.
William Rosener: Okay. And there's 910 three except for them.
William Rosener: Okay, once I've got this, I can simply copy this.
William Rosener: Paste it and change this to a two.
William Rosener: Okay, now I'm generating two integers one's been starting to mourn what's been studying. I've been into between one and 10
William Rosener: Okay.
William Rosener: Now what we want to do is the next step is we're going to take a look or allow the user to enter guess that will display either correct or incorrect. Let's take a look here, what this thing is called. This is called txt gas.
William Rosener: And LBO result.
William Rosener: So repress on check answer we come right up here and I'm going to take a look. His
William Rosener: Information and LBO demo on
William Rosener: Us.
William Rosener: That equal to
William Rosener: The gas.
William Rosener: And if so,
William Rosener: We call that that was an LBO result.
William Rosener: Correct.
William Rosener: Result equals incorrect.
William Rosener: In the estimate
William Rosener: Okay, so if the first number plus the second random number equals the guests and I'm going to display. Correct. And there'll be able to resolve always output incorrect in that particular label them.
William Rosener: Okay, let's go ahead and check it out to your I've got nine plus one. If I was to put in 10 showing up, it would say, click correct device to put in some other value I would get in. Correct. And let's just go ahead and quickly create this clear button.
William Rosener: And here I just need to say, I'm just going to go in and clear all this, I'll be on on these core values here.
William Rosener: And it will result.
William Rosener: In a set number two to double quotes
William Rosener: Okay, and let's just go ahead and try that. And it's clear. And sure enough, we've got that working so I can hit generate random numbers.
William Rosener: I can enter in my guests. I can check the answer and I can clear. Okay. The last piece of this little particular problem is we're going to very common programming.
William Rosener: Situation here is I have got some information I want to swap that I want to move this value over here and take what is in here and moved over here. Let's take a look at what these things are called
William Rosener: This one person, one is called
William Rosener: txt number one and this one is txt number two. And so I'm gonna go ahead and double click here on spot numbers. And initially, you might say, okay, txt number one is equal to extend them to and txt to is equal to txt number one.
William Rosener: Okay, but if I was to run that
William Rosener: He and press on it. I'm going to say it's not swapping them. What it did is began to swap it took this value and place to hear. Well, now this five is gone. So what we need to do is first of all store this in a temporary location then move the data and then finally move this one back.
William Rosener: OK, so the very first step I want to do is
William Rosener: And I should probably should be put in an attempt right here.
William Rosener: Only that if I put on Option Explicit I wouldn't get an error message here. So temp is equal to is equal to txt number one.
William Rosener: Okay, so what's going to happen is I'm going to storm.
William Rosener: This five and tea and temp.
William Rosener: Okay, so I'm gonna put the five in the temp and I want to take the 10 and put it in txt number one. And now what I want to do is take what's in tempt and put it back into txt number two.
William Rosener: Okay, let's go ahead and swap those
William Rosener: So I can see I successfully, no matter what day I put here in verse to change this when I hit the swap numbers seven came over here and the 43 one over there.
William Rosener: Well, from this video, you'll learn a lot about option buttons, checkboxes generate random numbers and even a really common application just taking that information and two different fields and swapping them. Okay, so next video. Thanks.