判断数组里是否有相同的值

今天上午因为工作的需要,必须要是实现判断数组里面是否有相同的值,有则不输出,否则输出。

由于我想可能以后在工作中还会遇到这样的情况,所以写了个函数,实现简单的功能。本人水平有限,望大家指个不足的地方。

'*****************************************
'功能: 判断数组里是否有相同的值
'  label为数组里分隔的符号
'  如数组为 a,b,c,d 则label 为","
'  如数组为 a|b|c|d 则label 为"|"
'  如果有相同的值则返回 0 否则返回 1
'作者:Poon
'创建日期:2006.5.24
'修改日期:2006.5.24
'*****************************************
Function IsSameValue(byVal str,byVal sValue,byVal label)
 On Error Resume Next
 Dim errMsg
 errMsg = "SYSTEM ERROR"
 If Not (IsNull(str) OR str = "") Then
  Dim splitStr, i
  If IsNull(label) Then
   IsSameValue = errMsg &"00001"
   Exit Function
  End If
  str = label & str & label
  splitStr = Split(str,label)
  If IsNull(sValue) Then
   IsSameValue = errMsg &"00002"
   Exit Function
  End If
  For i = 0 to Ubound(splitStr)
   If splitStr(i) = sValue Then
    IsSameValue = 0
    Exit For
   Else
    IsSameValue = 1
   End If 
  Next
 Else
  IsSameValue = errMsg &"00003"
  Exit Function
 End If 
End Function

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值