dim and redim allocate memory? 
Author Message
 dim and redim allocate memory?

Hi,

Does a dim statemen as in dim array(0) as string actually allocate memory or
is it nothing more than a declaration that needs to be initialized with some
values before memory is allocated.  What about redim?  Is memory being
reserved there?

Also C++ starts its array counters at 0 (a[0] is the first element). Does
Visual Basic the same or a[1] is the first element of the array?

Thanks for your time.



Fri, 12 Jul 2002 03:00:00 GMT  
 dim and redim allocate memory?
vb5 help under "ReDim Statement" keyword

konrad krupa

Quote:

>Hi,

>Does a dim statemen as in dim array(0) as string actually allocate memory
or
>is it nothing more than a declaration that needs to be initialized with
some
>values before memory is allocated.  What about redim?  Is memory being
>reserved there?

>Also C++ starts its array counters at 0 (a[0] is the first element). Does
>visual basic the same or a[1] is the first element of the array?

>Thanks for your time.



Fri, 12 Jul 2002 03:00:00 GMT  
 dim and redim allocate memory?
Dim is more of a compiler directive in that it establishes the type of
variable declared, reserving the appropreate amount of memory at compile
time.  Dim statements do not get executed at runtime.

ReDim is an executable statement, it therefore does allocate memory when
it executes.

The Option Base feature allows the programmer to determine if 0 or 1 is
used as the (default) lower bound value of an array.  This value should
be included in the Dim statement so there is no question about the lower
bound:

Instead of:

Dim Records(100)

Use:

Dim Records(0 To 100)

HTH
LFS

Quote:

> Hi,

> Does a dim statemen as in dim array(0) as string actually allocate memory or
> is it nothing more than a declaration that needs to be initialized with some
> values before memory is allocated.  What about redim?  Is memory being
> reserved there?

> Also C++ starts its array counters at 0 (a[0] is the first element). Does
> visual basic the same or a[1] is the first element of the array?

> Thanks for your time.



Fri, 12 Jul 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. De-allocating the whole array with ReDim() ????

2. Dim and ReDim?

3. Dim and ReDim

4. Dim and ReDim

5. Efficient use of strings (Dim, Redim, and all that)

6. ReDim a 2 dim. array

7. allocating memory

8. Allocating Memory and Structures.

9. Allocating memory

10. How to set free memory allocated by an array dynamically created

11. Allocate Memory

12. Question: Accessing memory allocated in DLL

 

 
Powered by phpBB® Forum Software