Ask a Question

Help on looping through data array

SOLVED
salley
Frequent Contributor

Help on looping through data array

Hello,
I need to iterate through the data and use them in username and password fields. user name a then password 100 ,, and then b 200. can somebody please look at my code and help please. thanks

Username Password
a|B|C 100|200|300

 

Set ObjExcelApp=Sys.OleObject("Excel.Application")
Set ObjWoorkBook=ObjExcelApp.Workbooks.Open("Path")
Set ObjWorkSheet=ObjWoorkBook.Sheets("Sheet1")
i=2
StrUname=trim(ObjWorkSheet.Cells(i,1))
StrPW=trim(ObjWorkSheet.Cells(i,2))
UArray=Split(StrClassCode,"|")
PArray=Split(strExposure,"|")

'I am just not sure how to loop through the data use them accordingly,,,,

For i=0 to Ubound(UArray)

for j=0 to UBound(PArray)
msgbox UArray(i)

MsgBox PArray(j)
Next
Next

1 ACCEPTED SOLUTION

Accepted Solutions
shankar_r
Community Hero

Re: Help on looping through data array

I guess you can do like below,


function CurDriverExample() { // Creates a driver DDT.ExcelDriver("C:\\MyFile.xls", "Sheet1"); var colSkipper = 0; // Iterates through records while (! DDT.CurrentDriver.EOF()) { //Gets a value from the storage and posts it to the log for(var c = colSkipper ; c < DDT.CurrentDriver.ColumnCount ; c++){ Log.Message(DDT.CurrentDriver.Value(c)); } colSkipper++;//to skip one col in each row DDT.CurrentDriver.Next(); } // Closes the driver DDT.CloseDriver(DDT.CurrentDriver.Name); }

Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

View solution in original post

4 REPLIES 4
shankar_r
Community Hero

Re: Help on looping through data array

Hi,

 

You need to create oleObject to use the excel [this way also we can do].

TestComplete provides in-build function to access the excel data using DDT drivers.

 

Example from Smartbear doc:

 

function CurDriverExample()
{
  // Creates a driver
  DDT.ExcelDriver("C:\\MyFile.xls", "Sheet1");
   
  // Iterates through records
  while (! DDT.CurrentDriver.EOF())
  { 
  //Gets a value from the storage and posts it to the log
    Log.Message(DDT.CurrentDriver.Value(0)); 
    DDT.CurrentDriver.Next(); 
  }
  
  // Closes the driver
  DDT.CloseDriver(DDT.CurrentDriver.Name);
}

 

Ref;https://support.smartbear.com/testcomplete/docs/reference/program-objects/ddt/exceldriver.html


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

salley
Frequent Contributor

Re: Help on looping through data array

Thanks for the reply, I can read the data what's I'm having trouble is with when I'm trying to split the data from the cell and using it,, for ex, I need to split the data from col A and Col B then use it, first iteration item 1 from col A then item1 from Col b, second iteration item 2 from col A and then Item 2 from Col B and do some task,,,,,, and so on,, I'm having trouble with writing this statement in loop. thanks

shankar_r
Community Hero

Re: Help on looping through data array

I guess you can do like below,


function CurDriverExample() { // Creates a driver DDT.ExcelDriver("C:\\MyFile.xls", "Sheet1"); var colSkipper = 0; // Iterates through records while (! DDT.CurrentDriver.EOF()) { //Gets a value from the storage and posts it to the log for(var c = colSkipper ; c < DDT.CurrentDriver.ColumnCount ; c++){ Log.Message(DDT.CurrentDriver.Value(c)); } colSkipper++;//to skip one col in each row DDT.CurrentDriver.Next(); } // Closes the driver DDT.CloseDriver(DDT.CurrentDriver.Name); }

Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

View solution in original post

salley
Frequent Contributor

Re: Help on looping through data array

Thank you so much for taking your time, i'm going to try it and will let you know if it works for me. once again Thanks

 

cancel
Showing results for 
Search instead for 
Did you mean: