Declaring Variables , Data Types and Examples are discussed in this session. For Complete powerpoint and related Free online class visit www.ameetz.com
2. Declaring Variables
A Variable is used to store temporary information that is used for
execution within the Procedure, Module or Workbook. Before
we go into some detail of Variables, there are a few important
rules that you must know about.
• A Variable name must Start with a letter and not a number.
Numbers can be included within the name, but not as the first
character.
• A Variable name can be no longer than 255 characters.
• A Variable name cannot be the same as any one of Excel's key
words. In other words you cannot name a Variable with such
names as Sheet, Worksheet etc.
• All Variables must consist of one continuous string of characters
only. You can separate words by either capitalising the first letter
of each word, or by using the underscore characters if you prefer.
4. Byte Data Type
Byte is VBA's smallest numeric data type
and holds a (natural) numeric value from 0
to 255. In this data type only positive
numbers to be used. Otherwise VBA will
return with an error.
Example for Byte Data Type :
Sub atz()
Dim Value As Byte
Value = 246
End Sub
We are going discuss more about Byte and cbyte() in future lessons