1

我编写了以下代码来获取组合中的所有元素并检查我所需的值,但我认为可能有更好的方法。检查组合框中是否有任何项目的更好方法是什么?无法从 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
4

1 回答 1

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
于 2010-07-16T12:28:53.417 回答