Why dim? or what does it mean?

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,516

SpillerBD

Well-known Member
Joined
Jul 2, 2014
Messages
2,694
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.
 

joeu2004

Well-known Member
Joined
Mar 2, 2014
Messages
2,580
Office Version
2010
Platform
Windows
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.)
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
18,185
Office Version
2013
Platform
Windows
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 !
 

joeu2004

Well-known Member
Joined
Mar 2, 2014
Messages
2,580
Office Version
2010
Platform
Windows
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.
 

Forum statistics

Threads
1,082,043
Messages
5,362,836
Members
400,694
Latest member
Sofie17

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top