Why dim? or what does it mean?

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Microsoft people?
It was just the convention began in other programming languages of the time.
JAVA and BASIC (and Visual BASIC) were born in different decades.
...and its declaring variables.
 
Upvote 0
The BASIC language predates MSFT by nearly 20 years. And even though I was there near the beginning and I was responsible for developing a commercial BASIC interpreter and compiler, I'm afraid those brain cells have weakened with time. But I do find some online references to confirm and refresh my recollections.

In the beginning, there were only numeric and string variables. A string variable name had a "$" suffix; otherwise, it was a "real" numeric variable (floating-point). No declaration was necessary.

The DIM statement was used only to declare the dimensions of arrays.

Much later, data typing was added in a variety of ways. There was no standard. (There is an ANSI standard now. But I cannot find a free reference online.)

Some versions of BASIC used a suffix (e.g. "%") for "integer" numeric variables. Some versions of BASIC had DECLARE and DEFINE.type statements. Some versions had INTEGER, SINGLE and DOUBLE statements.

And yes, MSFT VB extended the use of the DIM statement.

(Although one version of BASIC that I believe predates MSFT VB did allow for declaring non-array "real" variables names in the DIM statement. Again, the type was implied.)
 
Upvote 0
AND if you use Option Explicit in your code, and don't declare a variable, VBA will give you and error that you haven't declared your variable.
If you reread your link....halfway down the page...he tells you why you should declare !
 
Upvote 0
And yes, MSFT VB extended the use of the DIM statement.

Also note the Deftype statements; for example, DefInt, DefDbl, etc. But these are limited to the module level; that is, outside any procedure.

In another forum, someone speculated that MSFT extended DIM instead of creating one or more new statement types (e.g. DECLARE) in deference to backward-compatibility. I had thought of that, too. But I decided that is probably incorrect, since MSFT introduced other new statement types in VB.

I suspect that MSFT extended the DIM statement because it is was easier to integrate into the parser for the pre-existing versions of MSFT BASIC, and it might have required less additional programming. The issue is not the development effort, but the amount of memory required for the BASIC language processor. The DIM statement already had the components that are necessary to add a new variable.

Bear in mind that these language extensions came at time when computer memory was measured in KBs (multiples of 1024) and MBs, not GBs.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top