qtp中有没有一种方法可以检查组合框中是否存在该项目?

发布于 2024-09-09 22:17:28 字数 347 浏览 1 评论 0原文

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

I have written the following code to get all the elements in the combo and check with my required value, but i think there may be a better way. Whats the better method to check if any item is there in a combobox? couldnt get from the QTP help.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

榕城若虚 2024-09-16 22:17:28

没有这样的现成方法。您必须创建自己的函数。

如果您不关心已选择或将选择什么项目,请尝试以下操作:

' 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

There is no such method out-of-box. You'll have to create your own function.

If you don't care, what item was or will be selected, try this:

' 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文