Assignment #1A

  1. Open Microsoft Word.

  2. Create a blank document.

  3. Get the "Developer" tab visible in the ribbon. To do this, first press the "File" tab.

  4. Next press the "Options" button.

  5. Select "Customize Ribbon" and then turn on the "Developer" tab.

  6. You should now see the "Developer" tab displayed in the ribbon.

  7. Insert the text "Simple Calculator" and "Your Name". Then insert a 3x3 table by selecting "Table" under the tab "Insert".

  8. Merge the right cells by selecting them and then right clicking and selecting the option "Merge Cells".

  9. Insert the text "First number:", "Second number:", and "Answer". Then insert a "Text Box" in the top middle cell of the table by selecting "Text Box (ActiveX Control)" under the "Legacy Forms" in the "Developer" tab.

  10. Right click on the text box you just created and select "Properties."

  11. On the Properties window, give the textbox the name "txtNum1". Optionally change the "BackColor", "BackStyle", "BorderColor", "BorderStyle", "Font", and "Height".

  12. Copy and paste the textbox you just created into the middle row, middle column. Right click on this new textbox, and give it the name "txtNum2".

  13. Insert a label into the middle column of the last row, by selecting the "Label" option under "Active X Controls", "Legacy Tools" under the "Developer" tab.

  14. Right click on the label you just created and select "Properties." On the Properties window, give the label the name "lblAnswer". Optionally change the "BackColor", "BackStyle", "BorderColor", "BorderStyle", and "Font".

  15. Insert a command button into the last column, last row, by selecting the "Command Button (ActiveX Control)" option under "Active X Controls", "Legacy Tools" under the "Developer" tab.

  16. Right click on the command button you just created and select "Properties." On the Properties window, give the command button the name "cmdAdd" and the Caption "+". Optionally change the "BackColor", "BackStyle", and "Font".

  17. Double click on the command button you just created. This will open the code window for Visual Basic. Enter the text "Option Explicit" at the top. Then between the "Private Sub" and "End Sub" enter the text:
    lblAnswer = val(txtFirst) + val(txtSecond)
    This will add the values in the two textboxes and store the answer in the label.

  18. Close the Visual Basic code window by pressing the top "X". This will take you back to MS Word.

  19. Press the "Design Mode" button on the "Developer" tab. This button toggles between displaying the code and executing the code.

  20. Enter values in the textboxes for "First number:" and "Second number:". Then select the command button with the caption "+". When this button is selected the values in the two textboxes will be added together.

  21. Repeat this process for the command buttons for minus "-", multiplication "*", and division "/".

  22. Create a "Clear" command button. This will simply clear the values in the two textboxes and one label. Shown below is the code for the "Clear" command button.