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


Writing VBA Lesson Three

In the last lesson we looked at INTEGER variable and also naming conentions for integer variable. You don't have to follow our name convetion but it's a good idea to use something similar.

So, What Can We Name Variables and What Types are There?

You cannot have variables that start with a number or contain certain charcters e.g. spaces . , \ / ? -= + @. If you break this rule PowerPoint will warn you by turning the line RED. It is a very good idea to NOT use words already used by vba although this will not usually give an error.

Example Dim List as String - List is a reserved word

Note the use of naming conventions below. ixxx = INTEGER, strxxx = STRING, b_xxx = BOOLEAN type


So we learned INTEGERS are whole number positive or negative. Some believe that they can be from -255 to +255 but this is incorrect. The range is -2147483648 to +2147483648 which is enough for most uses.

PowerPoint itself rarely uses INTEGERS but uses instead the LONG type. These are also whole numbers but have a larger range -9223372036854775808 to -+223372036854775808. In most cases these two types are interchangeable. What type does PPT use?

This is good for whole numbers but what about decimals?

The type SINGLE can hold decimal numbers. The name creates confusion it is not for holding a single number e.g. 5. The easiest way to understand the limits is they will display eight "digits" accurately including the decimal point.

1234.567 will display OK

1234.56789 will round UP to 1234.568

1234.56711 will round DOWN to 1234.567

If you need more places use a DOUBLE type.

The next common type is STRING

A String can hold any text e.g. "John" Note it can also hold numbers but will treat them as text.

For example consider this code:

More bad code

This is what it should do. Set strNumber1 to 100 and strNumber2 to 99. Then ask is strNumber1 larger than strNumber2. If it IS give the first message and if not (Else) give the second message.

Run it and you will see PowerPoint cannot add up 99 IS larger than 100! This is because you have told it these are STRINGS (ie text) and it check ALPHABETICALLY 1 comes before 9 so it's smaller just like abc would be < xyz.

Last Type For Now (there are more to come)

BOOLEAN

This type can just store true or false.

EXAMPLE

Boolean

Summary

Integer type - WHOLE positive or Negative Number -2147483648 to +2147483648

Long type As Integer but -9223372036854775808 to +9223372036854775808.

Single type - 8 "digits" decimal (actually -3.402823E38 to -1.401298E-45 for negative values, and 1.401298E-45 to 3.402823E38 for positive values but it's easier to think of as 8 "digits")

Double type as above but "16 digits"

String - Text

Boolean True or False

NEXT Input need Input

 
 

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