8.1 Creating Multi-Factor Calculation Using Forms Part 3
8 hours 33 minutes
Okay, We're back in
and let's use this shape. And, uh, let's put some text here
and then let's see
Let's make it slightly bigger.
changes assistant old
sorry about that.
And yeah, we have.
Okay, so it's ah, little bit big. So it's ah, reduce it to todo
and yeah, we have this Don't still visible
s so it's, uh,
because slightly smaller.
like this. So start situation. We have this shape.
So it's click on this shape.
I'll get this
and then let's assign macro
and it's going to be just called right Triangle click. Let's do you
you're just going to hole this form
by clicking by typing user form one that show,
We just want to invoke this user form
in this moment.
that's it. We're going to save it.
We're going to close
when we click, we get our user form.
So let's type here some numbers.
Let's go. Thank calculate and we got the correct number. So we got to. That means that two fields have numbers
and was changed this
somehow. So it's good to hear
and maybe five here
and we still get to.
And if we clicked three here,
you'll get three. So
all three of field, this is not a
should be there. So we have to,
check s So so then the macro will have to act upon it and this place a message.
So at this point, we have finished
the testing off this phase of our A macro.
So let's close this
and let's go to a developer. Let's go to visual Basic.
Let's go. You can use your form
and let's look at the coat
so we don't need this message books here anymore. So let's, uh,
just put it
as a comment
and let's continue with the coat.
so at this point,
if C is not too, then we have to act upon it,
we have already, Detective, this is an americ, and ah,
we have checked that the third field
has no number in it
now. It can contain some texts.
Ah, but, uh,
So if one field contains text and the other two number,
uh, this macro will automatically assume that we have to put that in this dirt field, regardless of this, there is a text there or not.
So let's listen to complicate this and let's not complicate the logic. It would be,
ah, interesting to look at, uh,
if these fields are empty.
let's let's not do that at the moment. So let's say like this if
and then C is different than two. So what do we do then?
display message books,
says, for example,
to Mary Coe
you close this. So if c is different than do so if you have
other than two textbooks is filled with numbers release, play this message.
because this is going to be a structured if we're going to press, enter here
and do this
and, uh, yeah,
I hope raised message books
and then here
going type else.
And then let's see what happens.
so we're going to type if
we're going to see which to have numbers. So we know that to have numbers, but you know, to know which two.
So we're going to type if is America. So this is again the same function
box one the
Text box to you
then. So why, this
logical function and it turns through a false.
So if textbooks one and textbooks to our America,
we're going to get through and through, and we should say true and true, it's true.
So in that case, we know that we haven't. The user of this form has entered A and B
and we don't have in age, we don't have any number.
So we have to calculate the age
and then what we do with H.
We have to check
if textbooks one or a
is equal or greater zero because the side of the triangle cannot be
So just the check up. So we're going to say, Why didn't we do that before?
Ah, because, um,
we could have done it here. Here, where then is
and then we could make the structured if and then we could say then and then we had sequences C plus one. So we add one to see.
And then we could have added
if x books. One value is
greater than zero.
So if it isn't,
then ah ah, We have to
display a message that you have to enter Positive,
Billy. But let's do it here as well. Let's make
our life little bit interesting.
I want that value
lower or equal zero
Sorry. Textbooks to
was equal zero.
this is 00 Is my mistaking typing
And let's close this.
syntax is correct.
Then we'll just copy it
Here, we should have leased
and we don't need this anymore.
You could have vanity to or we couldn't done it like this.
So we also have to check what is
H or textbooks? Three. So we're going to do if
and then text books.
Three. That value
is different than empty.
and it should be
age has to be
So this'd is what we
did, you know.
And now we are sure that we have correct. Sign off numbers in boxes. Woman, too, and that textbooks three is empty so that they haven't entered anything in it.
And now we can proceed to calculation
and we're going to call. Results are
variable here, and it's going to be equal. Sq R or square root off
story textbooks one, don't you
times text books,
to that, will you
test box to the
We close it,
We have some typos
corrects it puts the space is the editor put spaces in the right places
and we have done that.
So now we have to put this value in the form
and, uh, step user
And also what we want to do is to
indicates somehow that we have calculated that field and that the result is there.
So user form
marks three that
holer some background color
equals. And let's put three be read. So plain red
Aunt, Here it is. And we have finished everything that we have to do.
Or this one. What we have to do back here is to
so if you remember, a single is single precision decimal number because this is going to be the civil number.
And so far we have finished
this just to remind you one thing. Look at these. If statements they don't have and if, why? Because we have just one thing after then and there is no else. So this is not block. If this is just plain if then structure
and we don't need to close it because it's in one line.
way have done the solution. If we are calculating h
let's say these two are not
numeric. So a and B are not the ones that Eric So let's go to A and h.
So do this. If we're going to create
And now if the America Off textbooks one value and in America textbooks, three value. So we're looking now toe a age.
So if these air numbers, then
if textbooks one really or textbooks three value
aren't smaller than or equal zero, then you can enter. Only positive number is
if textbooks three will you
ah different. Now it's we're looking at
sell two textbooks do. It has to be empty.
Village has to be empty. And here we have to do one more. Think
we're going to put another if statement. And we're going to say, if text
smaller or equal
to text books?
No, Well, you
then we have to display message
hypothesis has to be greater than both sides of a triangle.
So it's a
thing that we also have to check.
result is going Toby
textbooks. Will you three
textbooks, will you? One square.
if this is smaller than this, we're going to get negative value and error message resulting
because we're going to try to,
uh, calculate square root from the negative value.
And then we're going to put result in box, too, because B is now what we're calculating
the third possible result is that we have numbers in
B and age, so textbooks to in textbooks. Three. We don't have to ask that because we know it's there
and we're just going to
else here. Sorry
And then we're going to copy these lines.
Just changed the cell or boxes numbers.
let's make it
isn't America So we're looking now a text boxes two and three
also have two and three,
and then we're looking at textbooks one, is it empty or not?
And if textbooks three value is smaller than very textbooks to,
then we get here message H has to be greater than be.
And result is equal off
square root off
Xbox three, squared, minus textbooks to squared.
Envy of putting the result in the books one.
And now what we have to do is just close this if statements.
So we have to close this one. Sorry.
then we have to close
and we have to close the 1st 1
happens when you don't like well,
and, uh, that's it. This is our
We're just going to save it.
and that's it.