Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What am I missing here to return a value of True or False
VB
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
Posted
Updated 5-Nov-15 0:45am
v2
Comments
[no name] 5-Nov-15 6:59am    
Can you post your full function with function name?
RedJuice 6-Nov-15 1:09am    
Here is the full function


Function FindEnabledButtons
Dim p, w, robots, i, PropArray, ValuesArray

' Obtain the Notepad process
Set p = Sys.Process("Ribbon")

' Specify the sought-for property names
PropArray = Array("Value", "Value")

' Specify the sought-for property values
ValuesArray = Array("Sent", Found,)


' Find all enabled buttons in the Replace dialog
robots = p.FindAllChildren(PropArray, ValuesArray,1000)

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

1 solution

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:
VB
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900