在qtp中有一个方法来检查项目是否存在于组合框中?

时间:2010-07-16 09:08:06

标签: vbscript qtp

我已经编写了以下代码来获取组合中的所有元素并检查我所需的值,但我认为可能有更好的方法。什么是更好的方法来检查组合框中是否有任何项目?无法从QTP帮助中获得。

For check_index=0 to Window(window_name).Dialog(dialog_name).WinComboBox(control_name).GetItemsCount-1
If Trim(Window(window_name).Dialog(dialog_name).WinComboBox(control_name).GetItem(check_index))
=Trim(input_value_array(i_count)) Then

1 个答案:

答案 0 :(得分:0)

没有开箱即用的方法。你必须创建自己的功能。

如果您不在乎,选择了哪个项目,请尝试以下方法:

' try to select the desired value
yourCBO.Select "my item name"
' if it could be selected, then it does exist...
If yourCBO.GetSelection = "my item name" Then
MsgBox("exists")
Else
MsgBox("doesnt exist")
End If