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
Can anybody post some real time scenario in qtp? please its very urgent.
How to customize checkpoints with parameters?
When should I use smart identification?
In qtp, how you can exit for loop?
How should I click on the right click menu objects When I trying to add the object properties to the OR.It is showing only Window(Window).Not all the objects of the window. Also while recording I found No script. How to solve this>.
An action has both shared and local or associated to it and both have the same object in them. In the test which one will be considered?
If the objects hierarchy is changing from build to build, then how you will handle that condition?
Hello friends..... On which areas of an application we can not test with QTP
How will you compare keyword and expert view?
Hi All, I need code for how to execute qtp scripts from excell sheet
Where we use data driver in qtp?
Explain quicktest professional (qtp) testing process?
How do I lauch my test website using code from qtp in different environmet, uat and PPTE?
How do you perform Regreession Testing?
In the application that I'm testing is having a WYSIWIYG editor.QTP is recording editor's body as web element. I want to add some data to this web Element at run time. The problem is that I cant find a method to add contents to this web Element. Can any one come up with an answer for this. Thankx.