Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can we retain values in an array without destorying previous values
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Friends,

suppose we have stored 5 values in array. Later we decided to increase array size without destorying previous values. Is it possible to do that. If yes, Can you please share how can we do that?

For your understanding i am giving one Example:
Code:
a=array("a","b","c","d","e")

msgbox a(0)  'It displays a

ReDim a(15)
msgbox a(0)  'it displays empty value (How can I retain a(0) value)
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
You need to preserve the array elements using preserve keyword.

Use

Redim Preserve a(15)


Regards,
Ankesh
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Use "Preserve" keyword to retain value

Below is the example
Code:
a=array("a","b","c","d","e")

msgbox a(0)  'It displays a

ReDim Preserve a(15)
msgbox a(0)  'it retains value
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
Thanks Ankesh and SSvali, Its working fine
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  What are the QTP Runtime values kotaramamohana 0 2,134 05-21-2012, 10:21 AM
Last Post: kotaramamohana
  weblist values to display with help of datatable or msgbox kanna79 2 4,224 12-22-2009, 06:46 PM
Last Post: bfakruddin

Forum Jump:


Users browsing this thread: 2 Guest(s)