Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Send an object name (followed by a number) to ChildObjects?
#3
Solved: 11 Years, 6 Months, 3 Weeks ago
[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:
Code:
ChildObjects(oLevel & nLevel)
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:
Code:
nLevel = 1
sLevelString = "oLevel" & nLevel
Set List = parentFrame.ChildObjects(sLevelString) 'get childs from e.g. oLevel1 object
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"?
Reply


Messages In This Thread
RE: Send an object name (followed by a number) to ChildObjects? - by MGMN - 09-24-2008, 12:33 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to send/pass UFT Run Error Dialog as output value to main driver script lravi4u 0 729 11-05-2023, 03:55 PM
Last Post: lravi4u
  Send automatic email notification when test run started helmzshelmz 0 1,190 04-03-2020, 07:54 AM
Last Post: helmzshelmz
  Web Object Unique ID Number zunebuggy 0 1,653 07-10-2017, 05:37 PM
Last Post: zunebuggy
  To send Fail Results to mail Naresh 1 2,612 04-23-2015, 08:30 PM
Last Post: babu123
  To send the QTP Results to mail using Thunderbird Naresh 0 2,471 04-03-2015, 03:19 PM
Last Post: Naresh

Forum Jump:


Users browsing this thread: 2 Guest(s)