|
-
Jan 8th, 2007, 12:39 AM
#1
Thread Starter
Fanatic Member
searching array values in another array
hi, i have retreive my database values and stored in arrays ie i am retreiving worked dates ans stored the retreived dates in one array named as arr1.then i have some dates in another array named as arr2.so i want to
check whether arr2 dates are present in arr1 array,if present means i need to show the dates, please tel me how to do and please give me sample coding
-
Jan 8th, 2007, 12:50 AM
#2
Hyperactive Member
Re: searching array values in another array
 Originally Posted by karthikeyan
hi, i have retreive my database values and stored in arrays ie i am retreiving worked dates ans stored the retreived dates in one array named as arr1.then i have some dates in another array named as arr2.so i want to
check whether arr2 dates are present in arr1 array,if present means i need to show the dates, please tel me how to do and please give me sample coding
I don't know why you want to store your database query result in an array rather than in a recordset but anyway try this:
VB Code:
Dim ForCounter as Integer
Dim ForCounter2 as Integer
For ForCounter = 0 to Ubound(arr1).Count - 1
For ForCounter2 = 0 Ubound(arr2).Count - 1
If arr1(ForCounter) = arr2(ForCounter2) Then
'Dates Matched wohoo
Else
End If
Next
Next
Hope this helps you
Rate Me! Rate Me! Rate Me!
Time to fly.
Copyright GraysonSoft Inc. 2007
-
Jan 8th, 2007, 01:08 AM
#3
Thread Starter
Fanatic Member
Re: searching array values in another array
hi tommygrayson thanks a lot nice reply
-
Jan 8th, 2007, 01:57 AM
#4
Re: searching array values in another array
VB Code:
For Each dt As Date In arr1
If arr2.IndexOf(dt) <> -1 Then
MessageBox.Show(dt.ToString() & " is contained in both arrays.")
End If
Next dt
-
Jan 8th, 2007, 04:20 AM
#5
Thread Starter
Fanatic Member
Re: searching array values in another array
hi jmcilhinney,
if i use this it gives error:
over load resolution failed becos no accssible 'IndexOf' accepts this no of arguments
For Each dt As Date In arr1
If arr2.IndexOf(dt) <> -1 Then
MessageBox.Show(dt.ToString() & " is contained in both arrays.")
End If
Next dt
give me sugestion to recover that error please
-
Jan 8th, 2007, 04:31 AM
#6
Re: searching array values in another array
Ah, sorry. That's what comes from typing straight into the forum rather than pasting from the IDE. This:should be this:
-
Jan 8th, 2007, 04:34 AM
#7
Thread Starter
Fanatic Member
Re: searching array values in another array
hi jmcilhinney,nice very nice,i got it,cute reply,thanks a lot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|