'===============================================================================
'-函数名称: CheckAvg5
'-功能描述: 对比一组数据中满足指定数值的个数
'-输入参数说明: 参数1:strText 要比对的数据集
' 参数2:strfind 数据集的分隔符
' 参数3:avg5 要对比的指定数值
'-返回参数说明: 无
'-使用语法示例: checkavg5("22+20+20+22+23","+",21.4)
'-参考:
'-使用注意: 在分隔符中的必须是数字
'-兼容性: 97,2000,XP compatible
'-作者: victor_duane
'-更新日期: 2008-02-26 13:32
'===============================================================================
Function CheckAvg5(strText As String, strFind As String, avg5 As Double) As Integer
'比对一组数据中满足条件的个数
Dim strTextVal As String '修改要比对的数据集
Dim intPos As Integer '开始对比的位置
Dim intCount As Integer '计数
Dim dblCompare As Double '对比的数据
strTextVal = "+" & strText
intPos = 1
intCount = 0
Do While intPos > 0
intPos = InStr(intPos, strTextVal, strFind)
If intPos > 0 Then
intPos = intPos + 1
dblCompare = Val(Mid(strTextVal, intPos)) - avg5
If Abs(dblCompare) <= avg5 * 0.1 Then
intCount = intCount + 1
End If
End If
Loop
CheckAvg5 = intCount
End Function
http://programdesign.bbs.pepo.cn/page/bbs/pages/bbstopic/getTopicById.aspx?id=371962