Re: Values of Webtable to be stored in an array

2,408 views
Skip to first unread message

sujit kumar

unread,
Jun 20, 2012, 1:23:38 PM6/20/12
to mercu...@googlegroups.com, nikhil_rao2
Hi Nikhil

see function below

Rows=2
Cols=7
''all values stored in to Array bReturn

bReturn=GetTableValue(Rows,Cols)

Function GetTableValue(iRows,iCols)
Redim arrReturn(iRows*iCols)
       Dim iRowCount ,iColCount,iArrayIndex

iArrayIndex=0
For iRowCount = 0 to iRows-1
For iColCount = 0 to iCols-1
arrReturn(iArrayIndex) =Browser("MainBrowser").Page("PgName").WebTable("tblName").GetCellData(iRowCount,iColCount)
iArrayIndex=iArrayIndex+1
Next
Next
GetTableValue=arrReturn
End Function

feel free to ask if you have any query :)

-- 
Thanks  & Regards 
Sujit :) 

On Tue, Jun 19, 2012 at 11:59 PM, nikhil <nikhi...@gmail.com> wrote:
Hi I have a webtable with 2 rows and 7 columns. I need all the values. All these values
need to be stored in an aray as I will be using these values to compare with others.

--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en



sujit kumar

unread,
Jun 21, 2012, 12:28:13 PM6/21/12
to mercu...@googlegroups.com, nikhil_rao2

Hi Nikhil,
I have executed this Code in QTP11.It works
even u can return Array using Function


-- 
Thanks  & Regards 
Sujit :) 

On Thu, Jun 21, 2012 at 8:15 PM, nikhil <nikhi...@gmail.com> wrote:
hey thanks man, but I tried this already

getcelldata will never return an array. I still tries storing the values in an array what you have told but didnt work

afroz khan patan

unread,
Jun 23, 2012, 3:07:49 PM6/23/12
to mercu...@googlegroups.com

Hi nikhil,
in sujit code declare arrreturn() variable outside the function and no need to return array. Hope it works.

sujit kumar

unread,
Jun 24, 2012, 9:44:44 AM6/24/12
to mercu...@googlegroups.com
Hi   Nikhil /afroz

 Nikhil: Can u send me your code,so that I can find what exactly you are trying.
afroz: I have declare array variable in side of function 
   
       
-- 
Thanks  & Regards 
Sujit :) 

sujit kumar

unread,
Jul 9, 2012, 2:07:40 PM7/9/12
to mercu...@googlegroups.com, nikhil_rao2
Hi Nikhil,
 I checked this code in QTP11 it works.
can you tell me which version are you using,or is it license QTP or trial
there might be some problem in QTP version 
Or Try This
bReturn=GetTableValue("4","5")

Function GetTableValue(iRows,iCols) 'Takes parameters as String 
   Redim arrReturn(Cint(iRows)*Cint(iCols)) 'try to convert all iRows and iCols in Cint
       '''' Other also convert in Cint format, whenever require only
End  Function 

I am not sure why its happening.

-- 
Thanks  & Regards 
Sujit :) 

On Mon, Jul 9, 2012 at 9:37 PM, nikhil <nikhi...@gmail.com> wrote:
Hi Sujit,

Please see the code below:

bReturn=GetTableValue(Rows,Cols)

Function GetTableValue(iRows,iCols)
Redim arrReturn(iRows*iCols)
       Dim iRowCount ,iColCount,iArrayIndex

iArrayIndex=0
For iRowCount = 0 to iRows-1
For iColCount = 0 to iCols-1
arrReturn(iArrayIndex) =Browser("MainBrowser").Page("PgName").WebTable("tblName").GetCellData(iRowCount,iColCount)
iArrayIndex=iArrayIndex+1
Next
Next
GetTableValue=arrReturn
End Function


but QTP says invalid arguments when I'm calling the GetTableValue function. I'm passing just rowcount and colcount.

Can u explain what the problem.

For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

Mangalarapu Srinivas

unread,
Jul 9, 2012, 10:29:56 PM7/9/12
to mercu...@googlegroups.com
It is an array, U can't call directly, U have to follow array rules '

Msgbox   bReturn (1,1)

User Lbound and Rbound , run in the loop to get all the values

Regards,
Srinivas Mangalarapu



On Mon, Jul 9, 2012 at 9:37 PM, nikhil <nikhi...@gmail.com> wrote:
Hi Sujit,

Please see the code below:
bReturn=GetTableValue(Rows,Cols)

Function GetTableValue(iRows,iCols)
Redim arrReturn(iRows*iCols)
       Dim iRowCount ,iColCount,iArrayIndex

iArrayIndex=0
For iRowCount = 0 to iRows-1
For iColCount = 0 to iCols-1
arrReturn(iArrayIndex) =Browser("MainBrowser").Page("PgName").WebTable("tblName").GetCellData(iRowCount,iColCount)
iArrayIndex=iArrayIndex+1
Next
Next
GetTableValue=arrReturn
End Function
but QTP says invalid arguments when I'm calling the GetTableValue function. I'm passing just rowcount and colcount.

Can u explain what the problem.



On Wednesday, 20 June 2012 22:53:38 UTC+5:30, sujit wrote:

For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
Reply all
Reply to author
Forward
0 new messages