ray_mosley
10 years agoFrequent Contributor
Passing object property as parameter
I have an object which has both the PopupMenu and MainMenu properties.
I want to create a general function that will support "PopupMenu" or "MainMenu" as a parameter. Another parameter would specify the item to select.
This code Worked:
Function bClickPanelList(pobjItem, pDetailItem, pChildObject) If len(pDetailItem) < 3 and (asc(left(pDetailItem, 1)) > 47 and asc(left(pDetailItem, 1)) < 58) Then pDetailItem = aqConvert.StrtoInt(pDetailItem) End If If pChildObject = "" Or pChildObject = "PopupMenu" Then pobjItem.PopupMenu.Click(pDetailItem) Else pobjItem.MainMenu.Click(pDetailItem) End If End Function
This code did not work:
Function bClickPanelList(pobjItem, pDetailItem, pChildObject) If len(pDetailItem) < 3 and (asc(left(pDetailItem, 1)) > 47 and asc(left(pDetailItem, 1)) < 58) Then pDetailItem = aqConvert.StrtoInt(pDetailItem) End If newItem Eval(pobjItem & "." & pChildObject newItem.Click(pDetailItem) End Function
How can I pass the "PopupMenu" or "MainMenu" as a parameter to successfully execute the code without a check for the literal string?
Sounds like you'll want to check if the object supports one or the other.
Try using aqObject.IsSupported to see which the object supports and then call the function based on this result.