Hello and welcome.
In this lecture we are going to create the method for the operator click event just like we did with
the button click.
We are going to create a single method for the operator click event so I click on the one of the operators
which is the addition of the plus and I click here to access the events.
So under here I'm going to tie pin operator
on this call click.
So operator on this call click OK.
So the to access the code behind that is just double click inside here and that will open up the event.
So I'll just go back to the designer and what I'm going to do is copy this operator click and then use
that for whole the rest of the operator so I click on the minus.
I've come here a paste multiplication come here.
Paste the vision come here.
Paste doing it this way makes all the operators access a single method.
It's you know it's easier.
You write less code.
The first thing we want to do is create some variables that will store the operator value so any when
the appraisal values are clicked the value you want to store inside variables.
So gonna give defined that variables right at the top here gonna define it inside the class.
So let's create the first parable.
We're gonna make it a double data type and give it a name.
Can I give you the name of results.
I'll call it result value.
Okay.
And I'll set the initial value to 0.
Next variable I want to create is a string data type
and I'll call a swan
operator
operator clicked
call the operator clicked and I'll set the value to a blank value for now.
All right.
So let's go.
Not that we define the variables let's call back to the actual method here.
So we're going to define a piece of code here.
I'm gonna do I'm gonna just copy this line here.
We're going to reference that now pays that there next.
I need to reference the variable I created which is the operator click variable.
This variable here I referenced that and I am going to set that to equals to button
dot Tex
next some want to do is to pass the value from this result box in to the into the string.
This operation operator clicked someone to the past value into that so to do that and it specified some
code here.
So I'm going to reference the resultant value here which is is variable here.
It said double.
Someone would come here and reference it.
So I type in results
result in value.
And I'm going to set it because the result value here it's a double data type.
Need to do some conversion so that it can recognize that so I'm going to use a method called double
the pass to do the conversion.
So it will pass the message from the text box and convert it.
So it will convert whatever message is in this result box and convert it into the relevant value.
So inside this parenthesis here I need to specify the result.
The net result I need to call this value not text.
So that's where the conversion will take place so it will convert whatever is passed into that result
box.
So one more thing I like to do.
Before we wrap up this idea I want to implement some code for this clear button here.
I'm just going to double click on it and implement some code.
So we've now implemented the method or the code for the operator or click event.
We've also created some code for the club button so that you can clear the content of the result box.
Let's quickly run the program a click start and then we can test the the operators this operators will
not work at the moment because we have not written the code for the equals 2.
So we're gonna implement some code for these equals to before these won't will work but we can test
that declared button.
Now if I type in seven eight nine I click on Claire.
She returned to zero.
All right.
So the Claire button works for the OP for these operators to be activated.
We need to implement the code for the equals 2 and that will then work in tandem with these operators.
For now we are going to I'm going to end this lecture here.
Thank you so much for your time.
Take care.
Bye for now.
In the next lecture we will try and implement the code for this equals to sign.
Bye for now.