DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Find an item is existing in an array or not using Script

Solved!
Go to solution

Hi,

 

Want to know an easiest way to find if a particular element is exist in an array or not.

I have an array.

TestArray = Array("A", "B", "C", "D")

 

if some particular element is there in that array, based on availability condition, the script needs to be handled. whats the better way to do it.

 

Example:

if isinTestArray("C")  = True then

  'execute some lines

Else

   'execute some other lines

end if

 

regards,

Durai

 

0 Kudos
Message 1 of 2
(1,066 Views)
Solution
Accepted by topic author Durai26

 

 

Dim TestArray: TestArray = Array("A", "B", "C", "D")
Dim Item: Item = "C"

If Ubound(Filter(TestArray, Item)) > -1 Then
    MsgBox "Found"
Else
    MsgBox "Not found!"
End If

 

Source: https://stackoverflow.com/questions/11879612/qtp-checking-if-an-array-of-strings-contains-a-value

0 Kudos
Message 2 of 2
(1,042 Views)