Results 1 to 4 of 4

Thread: REDIM statement

  1. #1
    Join Date
    Jan 2009
    Posts
    74

    REDIM statement

    Hi, I want to get more information about the Redim statement which is used in the Visual Basic 6.0. Can anyone explain me. I have one book, but it is not giving me more information about it, as it has given only two to three lines information. So, just give me details about the Redim keyword.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: REDIM statement

    Hi, it is not that much big topic due to which it is giving you short description about the redim statement. So, just use the information to clear your concept and make use of it. Basically, this keyword used at procedure level to declare dynamic-array variables and allocate or reallocate storage space.
    Syntax:
    Code:
     ReDim [Preserve] varname(subscripts) [, varname(subscripts)] . . .
    The ReDim statement syntax has these parts:
    Preserve - Preserves the data in an existing array when you change the size of the last dimension.
    varname - Name of the variable;
    subscripts - Dimensions of an array variable;

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: REDIM statement

    Hi, ReDim statement is basically used to change the size of one or more dimensions of an array which size has been already declared. ReDim also help you to free up memory by reducing the array size. Or you can also increase your memory size by increasing the size of array with the help of RdDim statament.

    Syntax:
    Code:
    ReDim [ Preserve ] name(boundlist) [ , name(boundlist) [, ... ]]
    The ReDim statement is created only for arrays. Note that if you declare a variable to be of type Array, the ReDim statement does not have sufficient type information to create the new array. This statement will help you only help you at procedure level. Declaration context for a variable cannot be a source file, namespace, interface, class, structure, module, or block.

    Rules to be used to declare any ReDim statement:
    • You can specify only the Preserve modifier.
    • Resizing of different arrays at one time is possible, just separate that with comma.
    • Each entry in boundlist can specify the lower and upper bounds of that dimension.
    • It is possible to use -1 to declare the upper bound of an array dimension. TBasic).
    • The ReDim statement cannot change the data type of an array variable or of its elements.
    • It cannot provide new initialization values for the array elements.
    • The ReDim statement cannot change the rank of the array.
    • If you use Preserve, you can resize only the last dimension of the array.
    • You can use ReDim on a property that holds an array of values.
    • ReDim releases the existing array and creates a new array with the same rank.
    • If you do not specify Preserve, ReDim initializes the elements of the new array to the default value for their data type.
    • If you specify the Preserve modifier, Visual Basic copies the elements from the existing array to the new array.

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: REDIM statement

    Hi, REDIM statement Reallocates storage space for an array variable.
    It has following Behavior:
    Array Replacement-ReDim releases the existing array and creates a new array with the same rank.
    Initialization without Preserve- If you do not specify Preserve, ReDim initializes the elements of the new array to the default value for their data type.
    Initialization with Preserve-If you specify the Preserve modifier, Visual Basic copies the elements from the existing array to the new array.

    Example:

    Dim intArray(20, 20, 20) As Integer
    1. ReDim Preserve intArray(10, 10, 10)
    2. ReDim Preserve intArray(15, 15, 15)
    3. ReDim intArray(10, 10, 10)


    1. The first ReDim creates a new array which replaces the existing array in variable intArray. ReDim copies all the elements from the existing array into the new array. It also free 10 columns.
    2. The second ReDim creates another new array, copying all the elements that fit. However, It will add more 5 columns in this case.
    3. The third ReDim creates still another new array, removing another five columns from the end of every row in every layer. This time it does not copy any existing elements. This reverts the array to its original size and returns all its elements to their original default value.

Similar Threads

  1. How to use Else and Else If Statement in PHP?
    By Orton in forum Software Development
    Replies: 5
    Last Post: 05-03-2010, 06:49 AM
  2. How to use If statement in PHP?
    By Deabelos in forum Software Development
    Replies: 4
    Last Post: 09-02-2010, 06:14 AM
  3. HTML if else statement
    By Darthmouth in forum Software Development
    Replies: 3
    Last Post: 02-09-2009, 06:02 PM
  4. If Statement in HTML
    By Beatrisa in forum Software Development
    Replies: 3
    Last Post: 07-08-2009, 02:33 PM
  5. Replies: 4
    Last Post: 25-02-2009, 08:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,889,716.83217 seconds with 17 queries