ASP: FoundInArr 函数
作者:我就是个世界
发表于:2012-01-30
[code]
'函数:FoundInArr(strArr,strToFind,strSplit)
'作 用:检查一个数组中所有元素是否包含指定字符串
'参 数:strArr ----字符串
' strToFind ----要查找的字符串
' strSplit ----数组的分隔符
'返回值:True,False
'**************************************************
Public Function FoundInArr(strArr, strToFind, strSplit)
Dim arrTemp, i
FoundInArr = False
If InStr(strArr, strSplit) > 0 Then
arrTemp = Split(strArr, strSplit)
For i = 0 To UBound(arrTemp)
If LCase(Trim(arrTemp(i))) = LCase(Trim(strToFind)) Then
FoundInArr = True:Exit For
End If
Next
Else
If LCase(Trim(strArr)) = LCase(Trim(strToFind)) Then FoundInArr = True
End If
End Function
[/code]
例子:(在做动易的签收插件的时候用到了它)[separator]
[code]
If rsReceive.BOF And rsReceive.EOF Then
FoundErr = True
Response.Write "没有找到您要签收的文件!"
Else
If FoundInArr(rsReceive("ReceiveUser"), UserName, ",") = False Then '假如需要签收的用户字段中没有该登录用户
FoundErr = True
Response.write "该文件不需你单位签收!"
End If
If FoundInArr(rsReceive("Received"), UserName, "|") = True Then '假如已经签收的用户字段中有该登录用户
FoundErr = True
Response.write "您已经签收过此文章了,不需要重复签收!"
End If
End If
[/code]
'函数:FoundInArr(strArr,strToFind,strSplit)
'作 用:检查一个数组中所有元素是否包含指定字符串
'参 数:strArr ----字符串
' strToFind ----要查找的字符串
' strSplit ----数组的分隔符
'返回值:True,False
'**************************************************
Public Function FoundInArr(strArr, strToFind, strSplit)
Dim arrTemp, i
FoundInArr = False
If InStr(strArr, strSplit) > 0 Then
arrTemp = Split(strArr, strSplit)
For i = 0 To UBound(arrTemp)
If LCase(Trim(arrTemp(i))) = LCase(Trim(strToFind)) Then
FoundInArr = True:Exit For
End If
Next
Else
If LCase(Trim(strArr)) = LCase(Trim(strToFind)) Then FoundInArr = True
End If
End Function
[/code]
例子:(在做动易的签收插件的时候用到了它)[separator]
[code]
If rsReceive.BOF And rsReceive.EOF Then
FoundErr = True
Response.Write "没有找到您要签收的文件!"
Else
If FoundInArr(rsReceive("ReceiveUser"), UserName, ",") = False Then '假如需要签收的用户字段中没有该登录用户
FoundErr = True
Response.write "该文件不需你单位签收!"
End If
If FoundInArr(rsReceive("Received"), UserName, "|") = True Then '假如已经签收的用户字段中有该登录用户
FoundErr = True
Response.write "您已经签收过此文章了,不需要重复签收!"
End If
End If
[/code]
请发表您的评论