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