Presentation is loading. Please wait.

Presentation is loading. Please wait.

Calculator Program Explained by Arafa Hamed. First Designing The Interface Ask yourself how many places are there that will be used to input numbers?

Similar presentations


Presentation on theme: "Calculator Program Explained by Arafa Hamed. First Designing The Interface Ask yourself how many places are there that will be used to input numbers?"— Presentation transcript:

1 Calculator Program Explained by Arafa Hamed

2 First Designing The Interface Ask yourself how many places are there that will be used to input numbers? The answer is two places for first number and second number. Which object enables user to input data? The answer is Textbox control.

3 What is the data that will be displayed on your calculator project? There are many data will be displayed such as : Number 1 Number 2 Result So you must use the object which displays fixed data that can not be changed by user this control is : Label control.

4 Ask yourself How many mathematical operations will be done by your calculator and how will execute them ? The answer is many mathematical operations and to execute them you must build Button which is used to execute your codes. After all the previous answers. You can design your project as follow :

5

6 After finishing the designing such as shown on the previous step : Think with me after the user inputs the numbers how can the computer receive them to process them The answer is we have to build Variables * The variable is a reserved place in the memory, its contents can be changed during program running.

7 To build a variable in the code window double click on the button object then use this rule for building variables : Dim VariableName As Data type Another question : How many variables do we need and why ? The answer is 3 variables 2 for numbers and one for result. Think which kind of data will be used ? The answer is Decimal.

8 After that you can build the variables as shown : Notes : if you use ( integer, long, short) data types computer will ignore the fraction but if you use ( decimal, double, single) data types computer will process the fraction.

9 Let’s think how can the variables get the data from the TextBox object and store them on the memory till the processing happen on it. The answer is so easy by using: Assignment Statement Number1 = Textbox1.text Number2 = Textbox2.text Result = Number1 + Number2 As displayed in the following screen:

10

11 Dear students may I ask a question? Is that possible the user input letters instead of numbers onto the TextBox ? The answer is ……………… yes. How can you prevent that happen ????? The answer is by using ( try – catch )which is used to discover the errors during the running of program as displayed in the following screen :

12 *** If the user input letters instead of numbers an error message will appear as shown on the following screen: *** By the way we use MsgBox to display error messages. We type it as shown on the previous code window

13

14 The last question is How the contents of Result variable which is found on the memory will be displayed on the screen after the computer makes processing on the numbers ? The answer by using this code : Label4.text = Result as shown on the following : Notes we use Label to display the result so, no one can change this result.

15

16 At the last type the codes into each button Encapsulation means to hide your codes and no one can reach them without permission This is what you have done when type the codes into the object.


Download ppt "Calculator Program Explained by Arafa Hamed. First Designing The Interface Ask yourself how many places are there that will be used to input numbers?"

Similar presentations


Ads by Google