GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  QTP
Go To First  |  Previous Question  |  Next Question 
 QTP  |  Question 33 of 674    Print  
Hi i am new to VB Scripting, I have a problem to declare an array in QTP. I am using a variable to declare an array which is come in runtime.

Example:

Dim variable1 - declare the variable using dim
variable1 = "senthil" - assign the value which is come in run time
Dim variable1 (10) - declare the dynamic array using dim
variable1 (1) = "kumar" - store the value in array
variable1 (2) = "chandru" - store the value in array

This is the way i tried, but it show the error message like "Name redefined", Is there any possible options available for this, plz send me.

  
Total Answers and Comments: 9 Last Update: July 29, 2008     Asked by: p_senthil 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
April 19, 2006 01:26:03   #1  
sri        

you must give different name's for Variable and Array...

you must give different name's for Variable and Array.


 
Is this answer useful? Yes | No
April 19, 2006 01:31:23   #2  
Sri        

you must maintain different name's for Variable and Array...

you must maintain different name's for Variable and Array.

you can't take same flight ticket at a time. if you can you will get this problems.


 
Is this answer useful? Yes | No
April 19, 2006 06:36:55   #3  
p_senthil Member Since: April 2006   Contribution: 13    

RE: Hi i am new to VB Scripting, I have a problem to d...

Hi sri

Thanks for ur comment

Anyway i am not expect this answer i want to declare an array like senthil(10) and assing the two values can u understand this.

cheers

senthilkumar


 
Is this answer useful? Yes | No
April 28, 2006 09:29:04   #4  
p_senthil Member Since: April 2006   Contribution: 13    

Thanks

Hi sri

Thanks fro ur comments from ur comments i got answer for my problems i am really very sorry i misunderstand ur comments i have another problems in array is to pass the parameter in variable to array.

Example:

Dim myname

Dim myarray(100)

myname arra_para

myarray(myname) senthil ' pass the parameter by variable

Its like myarray( arra_para ) senthil

Please help me about this problem for how to pass parameter to array

cheers

senthil


 
Is this answer useful? Yes | No
August 08, 2006 04:25:29   #5  
Sri        

RE: Hi i am new to VB Scripting, I have a problem to d...

Array is access by script value. this value always represent an integer. in ur case try this :

VarName 1

ArrName(VarName) Senthil

u can also use FOR loop to pass more than one value in an Array.


 
Is this answer useful? Yes | No
May 04, 2007 06:28:49   #6  
jag        

RE: Hi i am new to VB Scripting, I have a problem to d...

Hi

Try to use declare

Dim variable1Arr ()
public varOne as integer

Inside the function

Redim variable1Arr(varOne)

Now your array value is passed with an integer.

Now write

variableArr(1) " Suresh"
variableArr(2) "Ramesh"


'Why iam giving Redim option means you said you want to declare dynamic array.


 
Is this answer useful? Yes | No
August 08, 2007 05:11:49   #7  
ritesh        

RE: Hi i am new to VB Scripting, I have a problem to d...
Now you are using the following script


Dim myarray(30)

myarray(0) raj
myarray(1) singh


msgbox myarray(0) & myarray(1)
in message box you can see the both value and use this for further action.

 
Is this answer useful? Yes | No
July 26, 2008 01:58:41   #8  
ashish3220 Member Since: July 2008   Contribution: 1    

RE: Hi i am new to VB Scripting, I have a problem to declare an array in QTP. I am using a variable to declare an array which is come in runtime.Example:Dim variable1 - declare the variable using dimvariable1 = "senthil" - assign the value which i
Dim variable1 (10)
variable1 (1) "kumar"
variable1 (2) "chandru"
print variable1(1)

 
Is this answer useful? Yes | No
July 28, 2008 15:11:12   #9  
Karimnazir Member Since: June 2006   Contribution: 3    

RE: Hi i am new to VB Scripting, I have a problem to declare an array in QTP. I am using a variable to declare an array which is come in runtime.Example:Dim variable1 - declare the variable using dimvariable1 = "senthil" - assign the value which i
You can daeclare a variable as under and then use it as an array:

dim a
a Array("kumar" "chandru" "abcd" "efghijkl")

You can test it like:
document.write(a(0))


output: kumar

Or

document.write(a(1))


output: chandru

Hope it helps

Karim

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape