寻找实现类似VB TypeOf或Java instanceOf (Java)的HP-UFT VBA代码
例如:我的存储库中有一个对象,它有一个类" webedit“,我想编写一个子过程来对它执行操作,但首先我想检查提供的对象是否为webedit
例如,下面是我想要的子过程
setIfNotBlank(
Browser("Google").Page("Search").WebEdit("SearchText")
, "Cute kities who actually rule the world" )
Sub setIfNotBlank( object , val )
if not ( object TypeOf WebEdit)
exit sub 'only proceed if WebEdit object
End if
object.set val
End Sub发布于 2017-08-01 14:34:25
从传递的参数中,我假设您已经将对象添加到对象存储库。将您的sub重写为:
Sub setIfNotBlank( object , val )
If IsObject(object) then 'First checking if the parameter "object" is actually an object
If strComp(object.getToProperty("Class Name"),"WebEdit",1)=0 then 'Checking the value of its property "class Name". It should be "WebEdit"
object.Set val
Else
Exit Sub 'If "object" is not of type "WebEdit", then Exit Sub
Else
Exit Sub 'If parameter "object" is not an object, Exit Sub
End If
End Subhttps://stackoverflow.com/questions/45429403
复制相似问题