Wednesday, December 2, 2009

Basic Calculator Program

I have made my own calculator! Using Microsoft Access, this is the crude Design View of my calculator.

Basic Calculator Programming Step No. 1: Create new blank form, click text box, create 3 blank text boxes. The computer will assign them their respective labels, e.g. Text0, Text 2, and Text4. Sometimes, the number at the end of the word Text varies so take note of this.

Basic Calculator Programming Step No. 2: Click buttons to create command buttons for addition (+), subtraction ( - ), multiplication ( * ), and division ( / ), as well as "clear".



Basic Calculator Programming Step No. 3: Right click on the command buttons, when the form wizard menu appears, click cancel. Right click again so that another drop down menu appears, go to "Event Builder", then click "Build Code". This will take you to the Visual Basic code builder to customize the commands for the basic calculator function buttons.



Basic Calculator Programming Step No. 4: For the addition (+) command button, type

Text0 = Val(Text2) + Val(Text4)

For the subtraction ( - ) command button, type

Text0 = Text2 + Text4

For the multiplication ( * ) command button, type

Text0 = Text2 * Text4

For the division ( / ) command button, type

Text0 = Text2 / Text4

For the "clear" command button, type

Text0 = " "
Text2 = " "
Text4 = " "

The program should be free of errors otherwise the debugger will appear highlighting in yellow your errors for correction.

Basic Calculator Programming Step No. 5: Go back to your crude calculator in Design View, refine the buttons a bit, and change to Form View. Voila! Your very own basic calculator!



*Note: It is best to try each command button if the first one is working properly. If so, you can simply copy + paste the line command and replace the symbols of the command function as needed, for your running program of a basic calculator.

No comments:

Post a Comment

Related Posts with Thumbnails
Related Posts with Thumbnails