首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在VB脚本中使用VB接口

在VB脚本中使用VB接口
EN

Stack Overflow用户
提问于 2013-02-14 16:39:33
回答 2查看 2.1K关注 0票数 0

我在HPQC的工作流程脚本上工作,并希望将示例中给出的一些VB代码移植到VB脚本。我不能让界面在VB脚本中工作。

VB代码:

代码语言:javascript
复制
 Dim iscp           As ISupportCopyPaste 
 Dim clipboard      As String

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

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

我尝试了一些webreferences,但不能理解它在VB script中是如何工作的。

请分享你的想法..也许给我指明了正确的方向..

EN

回答 2

Stack Overflow用户

发布于 2013-02-15 00:14:50

我在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中的tools -> references下的引用。
  3. 运行并享受其魔力:-) 3.

解决方案:

代码语言:javascript
复制
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
票数 0
EN

Stack Overflow用户

发布于 2018-02-02 02:01:28

enterSearchContent =Inputbox(“输入搜索内容”) entersearchterm =Inputbox(“输入搜索项”)

调用funcSearchContentMatchCount(enterSearchContent,entersearchterm)

函数funcSearchContentMatchCount(strsearchcontent,strsearchterm)

代码语言:javascript
复制
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

End函数

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14870761

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档