1.10 - Assignment for Tutorial 1
1... Start a New Project... Windows Application... OK
2... Add the following to the form: 4 buttons, 2 textboxes and one label. Arrange them so they form is similar to the following:
3... Set the following properties for the objects on the form:
Label1 | (Name) | lblTop |
BackColor | Green | |
Font | Arial, Bold, Size 10 | |
ForeColor | White | |
Location | 48, 9 | |
Text | Currency Converter | |
TextBox1 | (Name) | txtCanadian |
BackColor | Green | |
Font | Arial, Regular, Size 8 | |
ForeColor | White | |
Location | 20, 45 | |
Label2 | (Name) | lblCanadian |
BackColor | Green | |
Font | Arial, Bold, Size 10 | |
ForeColor | White | |
Location | 200, 48 | |
Text | Canadian $ | |
Label3 | (Name) | lblOther |
BackColor | Green | |
Font | Arial, Bold, Size 10 | |
ForeColor | White | |
Location | 200, 245 | |
Text | Other Amount | |
TextBox2 | (Name) | txtOther |
BackColor | Green | |
Font | Arial, Regular, Size 8 | |
ForeColor | White | |
Location | 20, 241 | |
Button1 | (Name) | btnUS |
BackColor | Green | |
Font | Arial, Regular, Size 8 | |
ForeColor | White | |
Location | 39, 86 | |
Text | US | |
Button2 | (Name) | btnUK |
BackColor | Green | |
Font | Arial, Regular, Size 8 | |
ForeColor | White | |
Location | 123, 86 | |
Text | British Pounds | |
Button3 | (Name) | btnCzech |
BackColor | Green | |
Font | Arial, Regular, Size 8 | |
ForeColor | White | |
Location | 123, 170 | |
Text | Czech Koruna | |
Button4 | (Name) | btnChina |
BackColor | Green | |
Font | Arial, Regular, Size 8 | |
ForeColor | White | |
Location | 39, 170 | |
Text | Chinese Yuan | |
Form1 | (Name) | frmCurrencyConverter |
Text | Currency Converter |
Your form should now resemble the following:
Now it's time for some code!!!
First, let's set up the code to convert Canadian dollars to US dollars.
Double ckick on the US button. When the code window appears, copy the following code:
Notice the green writing in the code, these are comments that help describe the code.
Run the program and make sure that when you enter a Candian amount, it is converted into US Dollars. Also, make sure the label changes to US Dollars.
Now it's time to write the code for the other buttons. Double click on the UK Pound button and write the necessary code (it will look similar to the above code).
The conversion
rates should be the following:
Canadian to US: Multiply
by 1.004
Candadian to UK Pound: Multiply by 0.512
Canadian to Chinese Yuan: Multiply by 7.231
Canadian to Czech Koruna: Multiply by 16.994
When you run your program now, you should be able to convert from Canadian dollars to each of the four currencies.
Now let's add one more
button, this will be a Clear button so that we can clear the amount in the Canadian
textbox.
The attributes for the new button
will be as follows:
The New Button | (Name) | btnClear |
BackColor | Green | |
Font | Arial, Regular, Size 8 | |
ForeColor | White | |
Location | 203, 121 | |
Text | CLEAR |
Double click on the CLEAR button and enter the following code:
Now try running your program.
If it is complete, call your teacher over to take a look.