Elementary Question: What is the purpose of DIM

cinders

Registered User.
Local time
Today, 19:03
Joined
Aug 28, 2001
Messages
48
Hello There,

I am reading through Access 2000 VBA Handbook by Susann Novalis. I haven't yet been able to find an explanation for using DIM. Can someone shed some light on this for me. I've searched the Access Help and could not find anything. I am stumped.

Thanks

Cindy (new to Access)
 
AFAIK, there is no consensus on why the particular word "Dim" is used (some say it's short for "Dimension"). It's kind of like saying "define", as in:
Define [this variable] As [this datatype]
 
Thank you,

I thought it had to do with defining variables, but the book I am reading has not stated that yet.

Thank you again
 
Seems like a rather basic thing. I'm not familiar with that particular book, but perhaps it's not for beginners, thus basic concepts are not explained.
 
Dim is short for Dimension.

From the top of the Access 97 Help:
Declares variables and allocates storage space.
In the early days you would have had to define exactly how much space your variable was going to take up in memory. ie the dimensions of the space used.
 
Dim isn't the only way to dimension a variable: there's also Global, Public, Private, and Static.
 
Didn't think we should be using Global any more? and just be using public instead.
 
Yeah, well it's still supported although the help entry for Global takes you direct to the Public entry.

I also forgot to mention the ReDim statement for arrays.
 
So:

dim used in subs and functions to declare the dimensions and type of a var.
static used in subs/funcs, same as dim, but the value is remembered and used next time sub/func is called.

public used outside subs and functions to declare a var that can be used by subs and functions in other modules.
private same as public, but can only be used by subs and functions in the same module.
const used outside modules, to declare a variable that isn't:) ie a variable that always has the same value.

redim used after an array has been dimmed to resize(re-dimension) the array.

That about right?
oh forgot to mention where i use modules i also mean classes and form code as well as seperate modules. Technically public/private are talking about the 'scope' of the variable, but you'll probly get to that later in the book.
 
Last edited:
cable said:
const used outside modules, to declare a variable that isn't ie a variable that always has the same value.

That'll be a Constant then :p

The only other declaration I can recall is Friend which is for declaring functions within class modules that you can call outwith the class.
 

Users who are viewing this thread

Back
Top Bottom