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
Astro Women - Birthdays
by Mona - Astronomy - 04/24/24 03:37 PM
2024 - on this day in the past ...
by Mona - Astronomy - 04/24/24 03:33 PM
Check Out My New Website Selective Focus
by Angela - Drama Movies - 04/24/24 01:47 PM
Psalm for the day
by Angie - 04/23/24 04:45 PM
Inspiration Quote
by Angie - 04/23/24 04:43 PM
Sew a Garden Flag
by Cheryl - Sewing Editor - 04/17/24 01:24 PM
Review - Notion for Pattern Designers: Plan, Organ
by Digital Art and Animation - 04/17/24 12:35 AM
Review - Create a Portfolio with Adobe Indesign
by Digital Art and Animation - 04/17/24 12:32 AM
Useful Sewing Tips
by Cheryl - Sewing Editor - 04/10/24 04:55 PM
"Leave Me Alone" New Greta Garbo Documentary
by Angela - Drama Movies - 04/09/24 07:07 PM
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