logo

Previous Thread
Next Thread
Print Thread
asp get distinct value #145143 09/10/04 07: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?

Re: asp get distinct value #145144 09/16/04 03:14 AM
Joined: Sep 2004
Posts: 2
jkody21 Offline
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 

Brand New Posts
2020: On this day . . .
by Mona - Astronomy - 11/29/20 09:50 AM
Container Gardening TIP OF THE DAY
by Lestie4containergardens - 11/29/20 05:13 AM
Native American Heritage Month
by Angela - Drama Movies - 11/29/20 01:25 AM
Advent 2020
by Angie - 11/28/20 11:18 PM
Thanksgiving and Gratitude
by Angie - 11/28/20 01:36 PM
Meanwhile in Canada
by Angie - 11/28/20 01:34 PM
Thanksgiving in Space
by Angie - 11/28/20 01:30 PM
The Solar System - for Kids & Others
by Mona - Astronomy - 11/28/20 12:39 PM
Uranus - Facts for Kids *new article*
by Mona - Astronomy - 11/28/20 12:36 PM
Sewing Ideas Towards Best Fit
by Cheryl - Sewing Editor - 11/25/20 09:36 PM
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!
Channel List
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies
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!
Sponsor


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


Powered by UBB.threads™ PHP Forum Software 7.7.3