返回正确或错误 [英] Return True or False

查看:78
本文介绍了返回正确或错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里错过了返回True或False的值

What am I missing here to return a value of True or False

If UBound(robots) >= 0 Then
    For i = 0 To UBound(robots)
      if (robots(i).enabled = true) then
        robots(i) = True
        robots(i).Click
      End If
    next
     robots(i) = True
      End If
End Function

推荐答案

一个Return语句?可编辑的代码?



Next 之后使用的索引器很糟糕 - 它超出了值的范围根据定义,数组。



假设你想要找到任何一个返回true,如果没有找到则返回false,那么试试这个:

A Return statement? Compilable code?

The indexer you are using after the Next is bad - it's outside the range of values for the array by definition.

Assuming that you want to return true if any were found, and false if none were found, then try this:
Dim result As Boolean = False
If UBound(robots) >= 0 Then
    For i = 0 To UBound(robots)
      If (robots(i).enabled = true) Then
        result = True
        robots(i).Click
      End If
    Next
End If
Return result


这篇关于返回正确或错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆