gpt4 book ai didi

vbscript - QTP:检查字符串数组是否包含值

转载 作者:行者123 更新时间:2023-12-04 13:01:59 25 4
gpt4 key购买 nike

我无法让我的测试用例正确运行。

问题出在下面的代码中,准确地说是第一个 if 语句。 QTP 提示需要一个对象

For j=Lbound(options) to Ubound(options)
If options(j).Contains(choice) Then
MsgBox("Found " & FindThisString & " at index " & _
options.IndexOf(choice))
Else
MsgBox "String not found!"
End If
Next

当我检查数组时,我可以看到它被正确填充并且 'j' 也是正确的字符串。
对此问题的任何帮助将不胜感激。

最佳答案

VBScript 中的字符串不是对象,因为它们没有成员函数。应该使用 InStr 来搜索子串。功能。

For j=Lbound(options) to Ubound(options)
If InStr(options(j), choice) <> 0 Then
MsgBox("Found " & choice & " at index " & j
Else
MsgBox "String not found!"
End If
Next

关于vbscript - QTP:检查字符串数组是否包含值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11879612/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com