Lesson#7 Variables and Data Types Flashcards
What is a variable?
A named storage location in your computer’s memory.
What two fields can you specify when declaring a variable?
Variable Name and Type of Data
After creating a variable how can you refer to it?
By using the specified variable name.
What are the 2 ways you can declare a variable?
Explicitly and Implicitly
What is the difference between Explicitly and Implicitly declared variables?
Explicitly declared variables are assigned a variable name prior to first use, Implicitly are not.
What is meant by the term data type?
Refers to how a piece of data is stored.
What happens if you do not declare the data type of a variable?
It is automatically given a Variant data type.
What is the basic structure of a variable declaration?
A keyword(Dim, Private, Public or Static), variable name and the ‘As’ keyword followed by the data type.
What are the 6 main data types you can work with?
Variant, String, Numeric, Date, Boolean and Object
What does the Variant data type allow you to store?
Almost any kind of data apart from fixed-length strings.
What does the String data type allow you to store?
Text
What does the Numeric data type allow you to store?
Numbers
What does the Date data type allow you to store?
Dates and Times
What does the Boolean data type allow you to store?
True and False
What does the Object data type allow you to store?
Object references and result in object variables.
What 3 types of textual data can String data types contain?
Letters, Numbers and Special Characters
What are the 2 types of String data type?
Variable-length and Fixed-length
In a Fixed-length string how do you specify the number of characters?
*
If the assigned data in a Fixed-length string is longer than the length given what happens?
VBA truncates the data.
If the assigned data in a Fixed-length string is shorter than the length given what happens?
VBA pads the data with trailing spaces
What are the 7 main numeric data types?
Byte, Integer, Long, Single, Double, Currency and Decimal.
What is the statement for assigning data to a variable?
VariableName = AssignedExpression
What is variable scope?
Refers to the parts of a VBA a project in which you can use a variable.
What is the default scope of a variable?
The procedure in which it’s declared
What is the default lifetime of a variable?
The time in which the procedure it’s declared in is running.
What are the 3 scopes a variable can have?
Procedure-level (local), module level (private) and global scope.
What 2 differences do static variables have to regular procedure-level variables?
Longer lifetimes and aren’t reset when the procedure ends.