Micro Focus QTP (UFT) Forums
How to get the total no. of columns used for a particular row - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to get the total no. of columns used for a particular row (/Thread-How-to-get-the-total-no-of-columns-used-for-a-particular-row)



How to get the total no. of columns used for a particular row - kumsweta - 12-02-2008

my code says .
DataTable.SetCurrentRow (2)
now i need to retrive the total number of column used in 2 nd row ..
is there any syntax
what is the substitute of "ddt_get_parameters" used in Winrunner in QTP ..

please reply asap


RE: How to get the total no. of columns used for a particular row - sreekanth chilam - 12-03-2008

Hi Swetha,

For retrieving the columns(Parameters) count in datatable, check the below code.

Code:
datatable.GetSheet("Sheetname").GetParameterCount

Try it n See .... u will get the columns count for any sheets in datatable easily...


Regards,
Sreekanth CR
sreekanth.chilam@gmail.com


RE: How to get the total no. of columns used for a particular row - kumsweta - 12-03-2008

Hi Sreekanth ,
This code retrives total column count of the sheet .
I want to retrieve column count of just 1 particular row ..
suppose i have 3 row .. 1 row has 6 colunm and 2 nd one has 3
third one has 4 .. so how to retrive the column count of 2nd row
please reply asap


RE: How to get the total no. of columns used for a particular row - kumsweta - 12-04-2008

Hi Sreekanth ,
This code retrives total column count of the sheet .
I want to retrieve column count of just 1 particular row ..
suppose i have 3 row .. 1 row has 6 colunm and 2 nd one has 3
third one has 4 .. so how to retrive the column count of 2nd row
please reply asap


RE: How to get the total no. of columns used for a particular row - bfakruddin - 01-03-2009

Code:
Dim rc,cc
rc=datatable.GetRowCount
msgbox rc

For i=2 to 2
    cc=datatable.GetSheet("Global").getparametercount
    msgbox cc
Next



RE: How to get the total no. of columns used for a particular row - sreekanth chilam - 01-03-2009

HI Swetha,

I wrote one user defined function which takes requires row number as an Input argument/Parameter.

1. Refer the below function defination :

Code:
Function Column_Count_Retrieve(Rownumber)
     Datatable.Getsheet("Global").SetCurrentrow(Rownumber)
     Temp=0  
            Col_Count=Datatable.GetSheet("Global").GetParametercount      
                 for j=1 to Col_Count
                         Val=Datatable.GetSheet("Global").GetParameter(j).Value
                               if Val<> "" then
                                     Temp=Temp+1
                               end if
                  Next
      msgbox   "Row  " &Rownumber&"   :   "&Temp&" rows"
End Function

2. Call the above function as given below :

Call Column_Count_Retrieve(3) ' Calling the function for finding the no. of columns used by 3rd Row
Call Column_Count_Retrieve(1) ' Calling the function for finding the no. of columns used by 1st Row
Call Column_Count_Retrieve(2) ' Calling the function for finding the no. of columns used by 2nd Row

I hope now your requirement has been solved.


RE: How to get the total no. of columns used for a particular row - nageshpv - 01-05-2009

Hello bfakruddin , i guess you need to change the code. Smile


RE: How to get the total no. of columns used for a particular row - bfakruddin - 01-06-2009

Sorry,
I have check only 2nd column, not for all rows... Sreekanth given beautiful code...
You can use that...


RE: How to get the total no. of columns used for a particular row - Sivakumar Munganda - 02-23-2010

Code:
datatable.columncount(rows)

webtable.columncount(rows)