Option Explicit
Public Function AscSum(CheckString As String) As Integer
' Calculates the sum of the ANSI codes for each character in a text string
' (-1 for zero-length strings)"
Dim Counter As Integer
If CheckString = "" Then
AscSum = -1
Exit Function
End If
AscSum=0
For Counter = 1 To Len(CheckString)
AscSum = AscSum + Asc(Mid(CheckString, Counter, 1))
Next
End Function
Public Function AscMin(CheckString As String) As Integer
' Evaluates each character in a text string and returns the lowest
' ANSI character code found. Empty strings evaluate to -1 (because
' there is an ANSI character 0)
Dim Counter As Integer
If CheckString = "" Then
AscMin = -1
Exit Function
End If
For Counter = 1 To Len(CheckString)
If Counter = 1 Then
AscMin = Asc(Left(CheckString, 1))
ElseIf Asc(Mid(CheckString, Counter, 1)) < AscMin Then
AscMin = Asc(Mid(CheckString, Counter, 1))
End If
Next
End Function
Public Function AscMax(CheckString As String) As Integer
' Evaluates each character in a text string and returns the highest
' ANSI character code found. Empty strings evaluate to -1 (because
' there is an ANSI character 0)
Dim Counter As Integer
If CheckString = "" Then
AscMax = -1
Exit Function
End If
For Counter = 1 To Len(CheckString)
If Counter = 1 Then
AscMax = Asc(Left(CheckString, 1))
ElseIf Asc(Mid(CheckString, Counter, 1)) > AscMax Then
AscMax = Asc(Mid(CheckString, Counter, 1))
End If
Next
End Function
|