What is the difference between Dim And Redim

Answer Posted / deepa

Dim Statement

Declares variables and allocates storage space.

Dim varname[([subscripts])][, varname[([subscripts])]] . . .

Variables declared with Dim at the script level are
available to all procedures within the script. At the
procedure level, variables are available only within the
procedure.

You can also use the Dim statement with empty parentheses
to declare a dynamic array. After declaring a dynamic
array, use the ReDim statement within a procedure to define
the number of dimensions and elements in the array. If you
try to redeclare a dimension for an array variable whose
size was explicitly specified in a Dim statement, an error
occurs.


ReDim Statement
Declares dynamic-array variables, and allocates or
reallocates storage space at procedure level.

ReDim [Preserve] varname(subscripts) [, varname
(subscripts)] . . .

The ReDim statement is used to size or resize a dynamic
array that has already been formally declared using a
Private, Public, or Dim statement with empty parentheses
(without dimension subscripts). You can use the ReDim
statement repeatedly to change the number of elements and
dimensions in an array.

If you use the Preserve keyword, you can resize only the
last array dimension, and you can't change the number of
dimensions at all. For example, if your array has only one
dimension, you can resize that dimension because it is the
last and only dimension. However, if your array has two or
more dimensions, you can change the size of only the last
dimension and still preserve the contents of the array.

The following example shows how you can increase the size
of the last dimension of a dynamic array without erasing
any existing data contained in the array.

ReDim X(10, 10, 10)
. . .
ReDim Preserve X(10, 10, 15)
Caution If you make an array smaller than it was
originally, data in the eliminated elements is lost.

Is This Answer Correct ?    20 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we create user defined functions in qtp?

559


How can I use Call dlls in QTP ?

1789


Have you used xml check point in your project? How?

549


How to connect the remote desktop using QTP 9.2 explain the method or procedure?

2801


How to Upgrade or support firefox 2.0 version on QTP 9.0? I have installed QTP 9.0 and installed firefox 2.0. But in REcord and Run Settings, it shows firefox 1.5 in Web tab for browser selection.

1787






Why qtp always start action1 and does not start action?

605


What is difference between run time object and test object?

558


I created 3 actions in test suppose I want to run action 1 in single time, action 2 is 4 time what I do?

599


Can any one tell me.......How the test engg's start testing in the compy environment.....real time tester PLSSSS help me i need in depth information regarding this...

1491


What are the various types of Actions in UFT?

591


How you are developing the script? Using record and play back or manual?

633


Qtp has been installed on my pc but recently ON opening it is giving this error PLEASE REPLY IT IS URGENT IT WAS WORKKING FINE QTPRO.EX THE instruction at "0x7.. ...". referenced memory at "0000....The memory could not be read... Awaiting QTP XPERTS REPly URGENT

2055


hi frinds i need help .i have 4 + yrs exp in testing and nearly 2 yrs exp in QTP and QC .currently iam working north fast 2 yrs iam looking for job in south is there any openings plz letme know my mail id is pbre1980@gmail.com

1571


What are the general steps involved in the data driven framework?

554


how can we compare descriptive programing with a regular expression

1925