Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is a value in an array
#1
Solved: 10 Years, 8 Months, 4 Weeks ago
I have a simple array I've defined.
I'm pulling a value into my datatable as a seperate action to use later.
Now I need to check my array and execute a line of code ONLY if the value I put into my datatable is present in the array.

Code:
TestArray = Array("value1", "value2")

TeWindow....TeField("FieldName").Output CheckPoint("GetValue")

If DataTable("GotValue", dtGlobalSheet) 'help me'  Then
...This code will execute if "GotValue" is in the TestArray
End If
Reply
#2
Solved: 10 Years, 8 Months, 4 Weeks ago
Code:
Function ArrayFind(arrToSearch,strToFind)
        Dim aIter
        For aIter=0 To UBound(arrToSearch)
            If Replace(Trim(arrToSearch(aIter)), chr(32), chr(160))=Replace( Trim(strToFind), chr(32), chr(160)) Then
                ArrayFind=aIter+1
                Exit Function
            End If
        Next
        ArrayFind=-1
    End Function

If ArrayFind(TestArray ,DataTable("GotValue", dtGlobalSheet)) <> -1 'help me' Then
...This code will execute if "GotValue" is in the TestArray
End If
Reply
#3
Solved: 10 Years, 8 Months, 4 Weeks ago
Suggest you to use a collection instead of an array
Reply
#4
Solved: 10 Years, 8 Months, 4 Weeks ago
Worth a try.. Think about it,
Join the array using the join keyword and then use the instr function to check if the string exist.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to convert a single dimension array to two dimensional array venkatesh9032 3 5,192 02-10-2014, 03:07 PM
Last Post: pranikgarg
  Adding array to another Global array in VB Script test911 1 3,008 12-02-2012, 12:40 PM
Last Post: parminderdhiman84

Forum Jump:


Users browsing this thread: 1 Guest(s)