Application that converts kilometres to miles per hour using for loop in WFA Visual C#
0 Comments


Hi there welcome to another C# video tutorial I’m Iosef Bodnar and In this C# video tutorial, I will make an application That will convert kilometers per hour to miles per hour using an Interval I have already done this form named Converter, and I’ve got those controls on this form this list box will display the conversion between kilometres per hour to miles per hour using this Interval which I will type in this box so this text box that represents the start speed as I Told you I will type the start speed the next box I will type the end of Speed and then last one. I will use for interval to type an Interval I’ve got three buttons the first one will convert the kilometers per hour to Miles per hour using this interval the next one. I mean this next button will clean all those controls and Exit a pattern will close this form and this application Okay, so let’s start to cut First I’m going to give a double click on this button convert and inside this method which is Linked to this pattern convert. I’m going to write a code So firstly I will declare a few variables And On this line, I’ll collect to declare a constant Which is going to hold the conversion factor between Kilometers and miles I Use a constant for that each conversion factor between the kilometers per hour to miles per hour because this conversion Factor is not going to be changed, and it’s a very good idea to use a constant for Values which are not going to be changed through the code so I Declared this double variable start speed which is a double real variable which is going to twist or double real numbers and I Use this classic inverter with this method to double to do the conversion from string to double and this Variable start speed is going to store this value That I will type in this text box and because all values typed the Text box is treat by C# compiler as a string. I must do this conversion from string to real number double so as You’ve been told this variable start the speed will hold that this value typed in this text box Which represents start speed and Next variables this end speed will hold this value type train and speed textbox and the interval this interval variable which is gonna to store integer variable because I use this in it before the interval a variable Is going to hold this value type in this box which represented interval So after all I use I declare another two Variables Double variables which I makalah to use those inside for loop okay, so as I told you I’m going to use a for loop This for loop will make the conversion will Compute a conversion from kilometers per hour to miles per hour and Will display all those conversions inside this list box After I will press this button comfort, so let’s make this So as European tout that is for loop will Computer converse conversion from kilometers per hour to mice per hour using this formula Which is going to Make the conversion between a kilometers per hour to miles per hour using this conversion factor Which is a constant double constant which I declared here on this line line 28 Inside this code and Here On the line 34 I used this List box to display the conversion inside this list box the conversion from kilometers Per hour to miles per hour so And For this button for next button I already done the code, it’s about this So you should write the name of Text box which you gonna to clear or which the button is gonna to clear it and After followed by equal and the codes and For this button exit. This method close is going to close the form and This application of course okay Let’s release Let’s first to compile at this application. Let’s release it Okay, so I don’t like here because the cursor is not focused on the first text box So I’m going to go back to my code, and I’m going to write here Focus method Which I went to to be on the first text box entities status speed box So I’m going to write a name for the start speed box Okay, let’s really second that this application and okay, let’s see what is going on On top water yeah, we should I change here Water, so I went here to be 0 1 2 3 4 5 6 7 8 9 okay, it’s alright good click on tap water again Let’s release again this application Okay, and now I’ve got the focus on the first text box let’s type the star speed. Let it be 1 and the end speed on this text box let be 150 and Interval 1 okay convert and here you go Here is the Conversion listed between a km/h, and miles per hour using this interval 1 so 1 Kilometer is equal with 0.6214 miles per hour and so on Ok let’s use another start speed 10 100 or let be let’s say 250 and interval 10 Convert here you go. Now you have conversion for each Kilometres that using this 10 intervals 2 Miles per hour so 10 a km/h is equal with six point 240 miles per hour 20 kilometers is equal with twelve point four to eight miles per hour and so on I want to give you a tip if you want to understand the application but you should use break point you go on the line where you want to set a Break point and after you go on Debug and click on this Toggle breakpoint, yeah Start Debugging Okay, type further values in our boxes here the for example 10 250 and for interval data click on convert button and click on step into Step into now the start speed as you can see if you go down in the locals start speed Was assigned with his value 10 Yeah now the cursor is in front of this loop For loop here and this Double variable was assigned by 10 here the test Was true so the cursor is gonna go inside this for loop and now it’s in front of this Formula which is gonna to do the conversion between kilometers hours and miles per hours and so on And Here in locals you can watch How this application is going to work Okay That’s all for today. Thank you for watching this video tutorial See you next time

Leave a Reply

Your email address will not be published. Required fields are marked *