2017-08-01 7 views
0

TypeOf関数の実装VBのTypeOf関数またはJavaのinstanceof(ジャワ)に似たものを実装してHP-UFT VBAコードを探してい

例:私はクラスの「Web編集」を持っている私のリポジトリ内のオブジェクトを持っていますそして私はそれに対してアクションを実行するためのサブプロシージャを作成したいのですが、最初のiは、提供されたオブジェクトは、例えば、ウェブ編集

は、ここで私はより

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 

答えて

1

したい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 Sub 
関連する問題