logo
Previous Thread
Next Thread
Print Thread
#145143 09/10/04 03:33 AM
Joined: Sep 2004
Posts: 1
winston Offline OP
Newbie
OP Offline
Newbie
Joined: Sep 2004
Posts: 1
hi,
i would like to compare an array against a pre-defined list and extract those values that does not match.
eg:
Predefined List
100
200
300
1100
400

Array
100
400
300

result : 200,1100


any ideas?

Sponsored Post Advertisement
#145144 09/15/04 11:14 PM
Joined: Sep 2004
Posts: 2
Newbie
Offline
Newbie
Joined: Sep 2004
Posts: 2
I wasn't sure exactly that you wanted to contain your predefined list, so I wrote the function to accept a comma-seperated-list (as a string) and then the array. Hope this is what you're looking for.

Code:
dim list, a

list = "100,200,300,1100,400"
a = Array("100","400","300")

Response.Write "OUTPUT: " & GetExcludedValues(a, list)


function GetExcludedValues(ByRef av_array, ByVal as_List)
	dim x
	dim y
	dim lv_arrTmp
	dim ls_Exitcode
	dim lb_MatchFound
	
	if not isArray(av_array) then
		GetExcludedValues = ""
		exit function
	end if
	
	lv_arrTmp = split(as_List, ",")
	
	
	for x = 0 to ubound(lv_arrTmp)
		lb_MatchFound = false
	
		for y = 0 to ubound(av_array)
			if lv_arrTmp(x) = av_array(y) then
				'---we have a match...don't capture value
				lb_MatchFound = true
			end if
		next
		
		if not lb_MatchFound then ls_Exitcode = ls_Exitcode & lv_arrTmp(x) & ","
	next
	
	'---if we have any elements that qualify, we will
	'   need to strip the trailing comma
	if len(trim(ls_Exitcode)) > 0 then ls_Exitcode = left(ls_Exitcode, len(ls_Exitcode) - 1)
		
	GetExcludedValues = ls_Exitcode	
end function


Moderated by  Lisa LowCarb 

Link Copied to Clipboard
Brand New Posts
Inspiration Quote
by Angie - 07/15/24 09:59 AM
Psalm for the day
by Angie - 07/13/24 09:27 AM
Guy Pearce Film "The Convert" Released Today
by Angela - Drama Movies - 07/12/24 05:30 PM
Sugarcane Trailer - Theatrical Release in August
by Angela - Drama Movies - 07/12/24 05:18 PM
A Designed Container Garden
by Angie - 07/11/24 11:50 AM
Crazy Tanager
by Angie - 07/11/24 11:45 AM
Wine Tastings
by Angie - 07/11/24 11:42 AM
America 250
by Angie - 07/11/24 11:34 AM
How do YOU Define Classical Music?
by Angie - 07/11/24 11:27 AM
What's in your closet?
by Angie - 07/11/24 11:24 AM
Sponsor
Safety
We take forum safety very seriously here at BellaOnline. Please be sure to read through our Forum Guidelines. Let us know if you have any questions or comments!
Privacy
This forum uses cookies to ensure smooth navigation from page to page of a thread. If you choose to register and provide your email, that email is solely used to get your password to you and updates on any topics you choose to watch. Nothing else. Ask with any questions!


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2022 Minerva WebWorks LLC. All rights reserved.


Powered by UBB.threads™ PHP Forum Software 7.7.5