123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <%
- '***************************************************************************
- ' 创 建 人:cuiwl (longchengfy@hotmail.com)
- ' 更新时间:2006-12-3 4:09
- ' 说 明:二维数组操作
- ' 数组多作为方便有效的存储实体
- ' 与数据库的操作相类似,一维字段名成,二维记录
- ' str = "issys:1"&chr(10)&"user:1,2,4,3"
- '***************************************************************************
- class arrayoperate
- public mark1,mark2,uarr
- public n, m
- private sub class_initialize()
- mark1 = ";"
- mark2 = chr(10)
- n = 0
- m = 1
- end sub
- private sub class_terminate()
- end sub
- ' 将相应的的 字符串 转换为二维数组
- public function stringtoarray(byval strpar)
- dim arr1,arr2,arr
- dim i
- arr2 = split(strpar,mark2)
- redim arr(3,ubound(arr2))
- for i=0 to ubound(arr2)
- strpar = arr2(i)
- arr1 = split(strpar,mark1)
- redim preserve arr1(6)
- arr(0,i) = arr1(6)
- arr(1,i) = arr1(4)
- arr(2,i) = arr1(1)
- next
- stringtoarray = arr
- uarr = ubound(arr2)
- end function
-
- '删除条件为第n个子元素等于key的二维数组元素
- public function arrayremove(byval arrpar, byval key)
- dim i,j,k
- k=0
- for i = 0 to ubound(arrpar,2)
- if arrpar(n,i) <> key then
- k = k+1
- for j = 0 to ubound(arrpar,1)
- arrpar(j,k-1) = arrpar(j,i)
- next
- end if
- next
- ReDim Preserve arrpar(2, k-1)
- arrayremove = arrpar
- end function
-
- '返回条件为第n个子元素等于key的二维数组元的第m个子元素的值
- public function arrayvalue(byval arrpar, byval key)
- dim i,j
- j = 0
- for i = 0 to ubound(arrpar,2)
- if arrpar(n,i) = key then
- j = j + 1
- arrayvalue = arrpar(m,i)
- end if
- next
- if j > 1 then arrayvalue = j
- end function
-
- end class
- '***************************************************************************
- ' 调用示例
- 'dim objarray: set objarray = new arrayoperate
- 'stringtoarray method:
- ' strvar = "issys:1"&chr(10)&"user:1,2,4,3"
- ' objarray.mark1=":"
- ' objarray.mark2=chr(10)
- ' ? = objarray.stringtoarray("strvar")
-
- 'arrayremove method:
- ' objarray.n = 0
- ' ? = objarray.arrayremove(arrpar,key)
- 'arrayvalue method:
- ' objarray.n = 0
- ' objarray.m = 1
- ' ? = objarray.arrayvalue(arrpar,key)
- 'set arrayoperate = nothing
- %>
|