PowerPoint FAQ
Word FAQ
Home Corporate Services FAQ Word Templates Training Nuclear Training Testimonials Contact Us

PowerPoint FAQ: Simple Calculations

You can create interactive simple calculations using controls available from the Control Toolbox.  These controls are designed to provide an easy way to assign code to perform functions when they are clicked.

Basically you insert textboxes and command buttons on your slides, name the objects, then assign code to them.  These objects are available from the Control Toolbox (View menu, Toolbars).  The downloadable file (zipped file) consists of one slide with the following controls:

  • Three textboxes named - Textbox1, Textbox2, Textbox3,
  • Two command buttons named - Calculate, Clear

The code behind the Calculate button reads as such:

Private Sub Calculate_Click()
On Error GoTo Err1
TextBox3.Value = TextBox1.Value * TextBox2.Value
GoTo Done
Err1:
MsgBox "You must enter numbers in both Value 1 and Value 2 before calculating", vbOKOnly, "Calculating Error Message"
Done:
End Sub

What is does is take what you typed in TextBox1 and multiplies it with what you typed in TextBox2.  It assigns that to the "Value" of TextBox3.  If it sees an error, it provides a message box.

The "Clear" button sets the values of the three textboxes to nothing ("").  This is referred to as an "Empty String", in other words NO TEXT (or numbers in this case).  The code to do this is:

Private Sub Clear_Click()
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
End Sub

The labels next to each of the three control textboxes are merely textboxes from the Drawing Toolbar.  They are simpler to create and since they don't require any code to be assigned to them, make more sense to use the regular features of PowerPoint instead of the objects available on the Control Toolbox.
 

Download File

To download the zipped file, click here.  Please keep in mind that this file (once unzipped) uses VBA and as such your Macro Security MUST be set to MEDIUM and you MUST click "Enable Macros" when asked.

If you would like to learn how PTT, Inc. can create customized presentations using VBA, contact us at info@pttinc.com.  Be sure to check out the CBT sample at http://www.pttinc.com/cbt_development.htm.