[thelist] VBscript array declaration puzzlement

John.Brooking at sappi.com John.Brooking at sappi.com
Thu Sep 16 08:24:55 CDT 2004


>> -----Original Message-----
>> Why does this
>>
>>     Dim aryPlanIDs(intCount)
>>
>> result in an 'expected constant' error, while
>>
>>     Dim aryPlanIDs()
>>     ReDim aryPlanIDs(intCount)
>>
>> seems to work fine?
>
>I agree that it's screwy, but VBScript doesn't allow variables when
>declaring array size with the Dim statement.  I'm sure under the hood there
>is a reason, but it eludes me.  FWIW, I find that array management is much
>easier in JScript.
 
Back in the early days of Visual Basic, I imagine it was because Dim
allocated static memory at compile-time, whereas ReDim allocated it
dynamically at run-time. With VBScript, I'm not sure there is still such a
strict distinction, but it's probably a carryover in concept if not in
actuality. Just my $.02.

- John
-- 
 

This message may contain information which is private, privileged or
confidential and is intended solely for the use of the individual or entity
named in the message. If you are not the intended recipient of this message,
please notify the sender thereof and destroy / delete the message. Neither
the sender nor Sappi Limited (including its subsidiaries and associated
companies) shall incur any liability resulting directly or indirectly from
accessing any of the attached files which may contain a virus or the like. 


More information about the thelist mailing list