Header
PowerPoint tips, hints and tutorials that will change your presentations for ever!

INDEX

 

Jigsaws
Sounds
Video
Custom Shows
vba code
NaviSlides
Games for teachers
Bullets
Triggers
Security
Flash Cards
Multiple Instances
PowerPoint 2007
Mail Merge
Random events
Animation
Hyperlinks
Set spellcheck language


Home buttonTutorial buttonContact buttonProducts button


Input Boxes

Inputboxes are used to get information from the user. Here is a simple example:

Input Text

It opens an InputBox with the heading "Type your name"and  sets the variable strRespose to whatever the user types in. Then it gives a message using the data.

This is fine and should never crash.

It's important to know that the response is always a String not a number. If your code EXPECTS a number PowerPoint will usually do some background conversion and come up with a sensible answer. NOTE - "USUALLY". Look at this code:

Not good!

Because you have declared iResponse as an Integer PowerPoint will convert the response to a whole number IF IT CAN. This is fine for 12 and 12.7 but what if the user types "12 years 5 Months"? Yep it crashes - there's no sensible way for a PC to convert a sentence to a number.

ALWAYS set the response to a String type and it will never crash. Once you have the answer you can test it. NOTE There are other ways to fix this error but this is fairly easy.

Test the response

This code takes the response as a String which will always work and then tests to see if it IsNumeric and only if it is uses the Integer variable.

Note also the use of 'TEST as a comment.

Comments begin with ' and show in GREEN. They just remind you what the code actually does. Comments never run as code they are ignored by PowerPoint vba.

 

Next Lesson If >> Then statements

 
 

Back to the Index Page

POWERPOINT BLOG

Articles on your favourite sport

Free Microsoft PowerPoint Advice, help and tutorials, Template Links
This website is sponsored by Technology Trish Ltd
© Technology Trish 2007
Registered in England and Wales No.5780175
PowerPoint® is a registered trademark of the Microsoft Corporation