在VB脚本中使用VB接口

时间:2013-02-14 08:39:33

标签: vbscript vb6 hp-quality-center

我在HPQC的工作流脚本上工作,并希望将示例中给出的一些VB代码移植到VB脚本中。我无法使接口在VB脚本中运行。

VB代码:

 Dim iscp           As ISupportCopyPaste 
 Dim clipboard      As String

 clipboard = iscp.CopyToClipBoard(sourceFolder.NodeID, 0, sourceFolderPath)

我无法在VB脚本中将iscp声明为ISupportCopyPaste。

我尝试了一些网络参考,但无法了解这在VB脚本中是如何工作的。

请分享你的想法..可能会指出我正确的方向..

2 个答案:

答案 0 :(得分:0)

我在http://go-gaga-over-testing.blogspot.com/2011/04/code-to-copy-test-set-from-one-folder.html找到了下面的代码示例。它演示了iSupportCopyPaste的使用,所以也许你可以适应它。

  1. 在excel vba编辑器中添加以下代码。
  2. 在工具下添加“OTA COM类型库”作为参考 - >来自excel的参考文献。
  3. 跑步并享受魔力:-) 3。
  4. 解决方案:

    Public Function CopyPasteTestSetFolder(sourceFolderPath, destFolderPath)
    
        strServer = "http://xyz/qcbin"
        strDomain = ""
        strProject = ""
        strUser = ""
        strPassword = ""
    
        Set objTDConnection = CreateObject("tdapiole80.TDCONNECTION")
        objTDConnection.InitConnection strServer, strDomain
        objTDConnection.ConnectProject strProject, strUser, strPassword
    
        Set objTreeManager = objTDConnection.TestSetTreeManager
        Set sourceFolder = objTreeManager.NodeByPath(sourceFolderPath)
        Set destFolder = objTreeManager.NodeByPath(destFolderPath)
    
        Dim iscp As ISupportCopyPaste
    
        Set iscp = sourceFolder
    
        clipboard = iscp.CopyToClipBoard(sourceFolder.NodeID, 0, sourceFolderPath)
    
        Set iscp = destFolder
        iscp.PasteFromClipBoard clipboard, destFolder.NodeID, 0, -1
    
        Set treeMng = Nothing
        Set sourceFolder = Nothing
        Set destFolder = Nothing
        Set iscp = Nothing
    
    End Function
    

答案 1 :(得分:-1)

enterSearchContent = Inputbox(“输入搜索内容”) enterearchterm =输入框(“输入搜索字词”)

调用funcSearchContentMatchCount(enterSearchContent,enterearchterm)

函数funcSearchContentMatchCount(strsearchcontent,strsearchterm)

If Typename(enterSearchContent) = "String"  Then
    If len(enterSearchContent) >0 Then
        strsearchcontent = Lcase(cstr(enterSearchContent))
    else
        msgbox "Content is blank"
    End If
Else
    msgbox "Not a valid string"
End If

If Typename(entersearchterm) = "String"  Then
    If len(entersearchterm) >0  and len(enterSearchContent)>len(entersearchterm) Then
        strsearchterm = Lcase(cstr(entersearchterm))
    else
        msgbox "Search Term is blank or Search Term Length is greater than Search Content"
    End If
Else
    msgbox "Not a valid string"
End If


arrstrsearchcontent = split(strsearchcontent," ")
intsearchterm = 0
intsearchtermExactMatch = 0
For i = 0 To Ubound(arrstrsearchcontent) Step 1
    If instr(arrstrsearchcontent(i),strsearchterm)<>0 Then
        intsearchterm = intsearchterm+1
        If strcomp(arrstrsearchcontent(i),strsearchterm,0) = 0 Then
            intsearchtermExactMatch = intsearchtermExactMatch+1
        End If
    End If
Next
TotalMatchCount = intsearchterm
TotalExactMatchCount = intsearchtermExactMatch
Msgbox "Total Number of occurences of Search Term is "&TotalMatchCount
Msgbox "Total Number of Exact occurences of Search Term is "&TotalExactMatchCount

结束功能