LOGO 首页 OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 技术文档 其他文档  
 
网站管理员

asp如何去除数组重复的数据

liguoquan
2023年8月18日 15:15 本文热度 2598
:asp如何去除数组重复的数据


<%
Function MoveR(Rstr)
Dim i,SpStr
SpStr = Split(Rstr,",")
For i = 0 To Ubound(Spstr)
If I = 0 then
MoveR = MoveR & SpStr(i) & ","
Else
If instr(MoveR,SpStr(i))=0 and i=Ubound(Spstr) Then
MoveR = MoveR & SpStr(i)
Elseif instr(MoveR,SpStr(i))=0 Then
MoveR = MoveR & SpStr(i) & ","
End If
End If
Next
End Function 
response.write MoveR("abc,abc,dge,gcg,dge,gcg,die,dir,die")

%>

<iframe id="aswift_1" name="aswift_1" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="854" height="0" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" src="https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-6370479498472259&output=html&h=280&slotname=6129565636&adk=3842234981&adf=3641306162&pi=t.ma~as.6129565636&w=854&fwrn=4&fwrnh=100&lmt=1692342823&rafmt=1&format=854x280&url=https%3A%2F%2Fwww.lmlphp.com%2Fuser%2F57910%2Farticle%2Fitem%2F2585586%2F&fwr=0&fwrattr=true&rpe=1&resp_fmts=3&wgl=1&dt=1692342823550&bpp=2&bdt=2758&idt=305&shv=r20230816&mjsv=m202308100101&ptt=9&saldr=aa&abxe=1&cookie=ID%3D37cf471cea7fa576-22ecca31aade00ce%3AT%3D1681548366%3ART%3D1689402950%3AS%3DALNI_Mb7-tBHbOXBuqxHP_M2z0H4N9m_Tw&gpic=UID%3D00000bf4b851950b%3AT%3D1681548366%3ART%3D1689402950%3AS%3DALNI_MZxETlQwAjL1W9vrpEsvyZrSxUBKA&prev_fmts=300x600&correlator=1385262228240&frm=20&pv=1&ga_vid=519501620.1681548365&ga_sid=1692342824&ga_hid=760591905&ga_fc=1&u_tz=480&u_his=1&u_h=720&u_w=1280&u_ah=680&u_aw=1280&u_cd=24&u_sd=1.5&dmc=8&adx=362&ady=731&biw=1263&bih=578&scr_x=0&scr_y=114&eid=44759837%2C44759876%2C44759927%2C31076469%2C31077148%2C44799580%2C44796897&oid=2&pvsid=894709231477277&tmod=893709583&uas=3&nvt=1&ref=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3DsUCC-xlhJY00t7YRI1mpid_Y_PwaY7rHVYlGO3XspNM_yyahGJ2dELpTUltvFs8DpGOlprZV5gnTIv1SvC5eeh6oAY_ZYCcxKqaWkRrOfIW%26wd%3D%26eqid%3D84bcff460002d2950000000664df1a12&fc=896&brdim=0%2C0%2C0%2C0%2C1280%2C0%2C1280%2C680%2C1280%2C578&vis=1&rsz=%7C%7CeEbr%7C&abl=CS&pfx=0&fu=128&bc=31&ifi=2&uci=a!2&btvi=1&fsb=1&xpc=lN0vWk8Llp&p=https%3A//www.lmlphp.com&dtd=314" data-google-container-id="a!2" data-load-complete="true" data-google-query-id="CKyy86bU5YADFYtgDwIdZsEAFA" style="left: 0px; position: absolute; top: 0px; border-width: 0px; border-style: initial; width: 854px; height: 0px;"></iframe>

结果是:abc,dge,gcg,die,dir

如果是两个数组进行对比,去掉相同的数组元素:

<%
		Function mover(farray,sarray)
		a = Split(farray, ",")
			Set dic = createObject("scripting.Dictionary")
			For k=0 To UBound(a)
			 If a(k)<> "" Then dic.Add "_" & a(k), a(k)
			Next
			a = Split(sarray, ",")
			For k=0 To UBound(a)
				If a(k)<> "" Then
					If dic.Exists("_" & a(k)) Then
					dic.Remove "_" & a(k)
					End If
				End If
			Next
			items = dic.Items()
			Set dic = Nothing
			moveR=Join(items, ",")
		End Function
n1 = "a,b,1,11,12,13,14,15,16,17,19,20,22"
n2 = "a,1,12,14,18,19,20"
response.write mover(n1,n2)
%>

结果是:

3.数组A中有为空的元素(如a=array("ww","ss","","dd","","ee")),

想把这些空元素从数组A中去掉.并把去掉空元素有的数组赋给数组B.
str=""
for i = lbound(A) to ubound(A)
if A(i)<>"" then
if i<>lbound(A) then str = str + "," end if
str = str & A(i)
end if
next
b = split(str,",")

该文章在 2023/8/18 15:15:20 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2026 ClickSun All Rights Reserved  粤ICP备13012886号-2  粤公网安备44030602007207号