[EDIT: I have thanks to niranjan's tips about the Case statement (see the answer above) found a solution that works, but my question still remains and can make it easier to handle bigger iterations.]
Yes, a Case statement is another (maybe smarter) solution, but my problem isn't the For-Next loop. My problem is that I don't know how to concatenate the string "oLevel" with iteration number "nLevel" into "oLevel1" so it is sent as an object to ChildObjects.
It doesn't seem to be possible to concatenate "oLevel & nLevel" into an object like this:
When looking at this code now it seems logic that it didn't work since the "oLevel" variable doesn't actually exist.
However I have tried one more solution and that is to set the letters in "oLevel" to a string and concatenate this string with nLevel into "oLevel1" before sending it to ChildObjects. This solution was something like this:
But this didn't work either. Unfortunately I'm not at my QTP machine now to try it out and it was a couple of hours since I tried it so I'm not 100% sure about the code.
But the question remains; how can I concatenate a number and a string in order to send the object "oLevel1"?
Yes, a Case statement is another (maybe smarter) solution, but my problem isn't the For-Next loop. My problem is that I don't know how to concatenate the string "oLevel" with iteration number "nLevel" into "oLevel1" so it is sent as an object to ChildObjects.
It doesn't seem to be possible to concatenate "oLevel & nLevel" into an object like this:
Code:
ChildObjects(oLevel & nLevel)
However I have tried one more solution and that is to set the letters in "oLevel" to a string and concatenate this string with nLevel into "oLevel1" before sending it to ChildObjects. This solution was something like this:
Code:
nLevel = 1
sLevelString = "oLevel" & nLevel
Set List = parentFrame.ChildObjects(sLevelString) 'get childs from e.g. oLevel1 object
But the question remains; how can I concatenate a number and a string in order to send the object "oLevel1"?