Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check if a value exists in an array

Status
Not open for further replies.
Oct 11, 2006
300
US
Hi,

I populate a recordset and dump it into an array.

How can I check if a value exist in the array?

I want to check if the c_Member_mgr has a particular value or not?

Code:
Dim rs2
		set rs2 = Server.CreateObject("ADODB.Recordset")
		rs2.open sub_Emp_Source, Conn


		Dim aSubordinates

		If not rs2.EOF then
		
			aSubordinates = rs2.GetRows()

			'Close Recordset to use the new array with the 2 columns data
			rs2.Close()
			set rs2 = Nothing

			'Declare Constants for the above SQL columns for better readability
			'Use these Constants instead of referring to the array numeric indexes
			Const c_Member_Mgr = 0
			Const c_Subordinate = 1
			Const c_EmpID = 3
			Const c_EmpName = 4
 
something like this:

Code:
numcols=ubound(aSubordinates ,1)
numrows=ubound(aSubordinates ,2)
FOR rowcounter= 0 TO numrows
  FOR colcounter=0 to numcols
      if isnull(aSubordinates (colcounter,rowcounter)) then
         'the value is empty
      else
         ' it is not empty
      end if
   NEXT
NEXT

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top