| 1. |
You are to create a calculator. When
you enter two numbers, you will be able to add, subtract, multiply and
divide the numbers. |
| 2. |
Prepare a TOE Chart before beginning to
build the interface. |
| . |
|
| 3. |
Create a new application and name the
project calculator. |
| . |
|
| 3.1 |
The name of the form should be
frmcalculator. |
| 3.2 |
Change the forms’ Text property to
Computer Calculator. |
| 3.3 |
Set the WindowState property to Maximized. |
| 3.4 |
Assign the filename calculator form file
object. |
| 3.5 |
Set the project’s startup form to
frmcalculator. |
| . |
|
| 4. |
In the center of the top of the form,
create a label named lbltitle and change the Text property to Calc You
Later Inc. |
| . |
|
| 4.1 |
Set the TextAlign property of the lbltitle
object to MiddleCenter. |
| 4.2 |
Set the Font property so it is large enough
to fill the label box you drew. |
| 4.3 |
Create two graphics to hold icons on either
side of the lbltitle. Use Google to locate two suitable pictures. |
| . |
|
| 5. |
Create two text boxes, with two labels
above them to hold the numbers. |
| . |
|
| 5.1 |
The text boxes should be called txtnum1 and
txtnum2. |
| 5.2 |
Set the TabIndex property of txtnum1 to 0
and the TabIndex property for txtnum2 to 1. |
| 5.3 |
Set the Font property so it is large enough
to fill the text boxes and the label boxes you drew. |
| 5.4 |
There is no need to name the labels. |
| . |
|
| 6. |
Create a label box to hold the answer of
the calculation. |
| . |
|
| 6.1 |
Set the BorderStyle property to Fixed3D. |
| 6.2 |
Name the label lblanswer. |
| 6.3 |
Set the Font property so the text is large
enough to fill the label box you drew. |
| 6.4 |
Create a label box above the lblanswer
object and change the Text property to Answer. Select an appropriate
font and size for this label. |
| . |
|
| 7. |
Create four buttons below the lblanswer
object and align them centered. |
| . |
|
| 7.1 |
Call them btnadd, btnsub, btnmult, and
btndivide and set the button’s Text property to the words
“&Add”, “&Subtract”, “&Multiply”, and
“&Divide” without the quotes. |
| 7.2 |
Pick an appropriate font and size for the
words. |
| 7.3 |
Double click on the Add button object to
enter the code window and write the appropriate code to the button
object to calculate the answer (You will need to use the VAL function to
convert the text to numbers so the calculation can be performed
properly.
(lblanswer.Text =
Val(txtnum1.Text) + Val(txtnum2.Text) |
| 7.4 |
Repeat step c (above) for the Subtract,
Multiply, and Divide buttons, modifying the formula as necessary. |
| 7.5 |
Try the above formula without the Val
function to see how Visual Basic .NET treats addition of text. |
| . |
|
| 8. |
Set the Form’s AcceptButton property to
the Add button. |
| 9. |
Double click anywhere on the form object
and in the code window set the focus to the first number box by adding
the following code in the frmcalculator_Load section txtnum1.Focus() |
| . |
|
| 10. |
Create a fifth button and place it centered
at the bottom of the screen. |
| . |
|
| 10.1 |
Call it btnexit and set the button’s Text
property to the word “E&xit”, without the quotes. |
| 10.2 |
Pick an appropriate font and size for the
word Exit. |
| 10.3 |
Double click on the button object to enter
the code window and add the appropriate code to the button object to end
the application. |
| . |
|
| 11. |
Save the solution, then start and test the
application. Make sure you test each button. Close the application. |