Hello and welcome.
In this lecture we are going to continue from where we left off in part one.
All right.
So I'm just going to change some more of the property values so if click on the label here I'm going
to remove the text value which is this one here.
I don't want it to say anything at the moment but just get rid of that and that should be gone next
and I want to do is go to the buttons tab
and I want to change the text on that button.
Just make that okay button.
Change that too.
OK.
All right.
So I'm good.
The next time we want to do we want to try and understand how they can be a data type assignment mismatch.
So to do that double click on the okay button double click.
And that should open up the code behind the button
if you don't get this pop up immediately click you make sure you click on this.
Default is default dot SB X dot see us make sure that is clicked on also before you double click on
the button.
If it doesn't come up.
So right.
So this is the this is shown all our code.
So because we've clicked on the button you can see the mouse the cursor is flashing there because that's
where it's asking us to insert some code.
All right.
So what I'm going to do I'm going to try and it's OK.
So let's start with a data type of integer.
All right.
I'm going to give it a value of just the letter I type in the name the variable and then I am going
to introduce a data type mismatch what I'm gonna do for the value of i I'm going to enter a string value.
So I'm going to say
hello world
okay.
And post semicolon at the end.
All right.
You can see Vicious to those complaining because of the squiggly lines.
So in knows that I've got the wrong data type inserted the red squiggly on the line here indicates a
compilation era where the application will not run as opposed to a green squiggly line.
So if you have a green squiggly line that is just a warning does doesn't stop the code from running.
The reason we have the red squiggly lines is because we are trying to put a string which is an alphanumeric
characters into a variable that is only able to hold an integer an integer basically is a whole no value.
So the variable is saying I'm not having that.
So that we can't accept string values in this variable figure is quite good.
If you hover your mouse over that it will tell you what's gone wrong.
And you know basically give you a clue as to what's going on.
So what are we going to have to do we going to have to do an explicit conversion an implicit conversion
basically is done with data with data of all values of similar data types when they have similar data
type like a string on a string or an integer an integer that is known as implicit whereas the data types
are different.
For example an integer and the string that is explicit.
So we need to do an explicit conversion.
So to to convert this value into an integer value we are going to use a method a method called convert
dot to int 32 method.
Basically what this method does it will convert the specify string to an equivalent 32 bit signed integer.
So this is all going gonna do where we've got the variable I want to set it to equals to look type in
the world convert
uppercase
convert dot you notice it's the intelligence has given us an idea.
This is what I want.
So I'm gonna convert convert dot to 32.
That's the method.
And then in parentheses I'm going to includes the text.
I want to convert.
So if she can see this quickly red squiggly lines has disappeared because we've now used this convert
dot to into 32 method to convert this text hello world into an integer value.
So this value now is equivalent to a 32 bit signed integer so a 32 bit side integer is also equivalent
to the number in the value or a zero.
If the value is no.
So I'm just going to go in to design you for a minute or just scroll down
and in the design of your what I'm trying to achieve here this text box here the text box input it will
store users the input as a string but what I'm trying to achieve here I want doors to be able to convert
that string into an integer so we can performs some calculation on it the label control which is this
one here.
So the result as a string.
So we will also want to convert the results of the into calculation back into a string.
So we're going to see if we can achieve that in the next lecture.
So that's it for this lecture.
Thanks for watching.
Bye for now.