Help on looping through data array
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
