PDA

View Full Version : Usage of TALLY Keyword



Michael Clease
29-05-2007, 14:44
' Usage of Tally Keyword
' n = TALLY(MainString, [ANY] MatchString)
' Return the number of occurrences of specified characters or strings within a string.
' Written by Abraxas

DIM MainString as string value "HELLO a bb cc WORLD"
DIM LowerAlpha(26) as byte
DIM UpperAlpha(26) as byte
DIM count as DWORD VALUE 0
DIM sMsg as string

sMsg = " Character Count" & $CRLF & $CRLF
sMsg += "CHAR" & $TAB & "UPPER" & $TAB & "LOWER" & $CRLF & $CRLF

'Count Characters and Display the counts
for count = 1 to 26
Loweralpha(count) = TALLY(MainString, any chr$(count+64)) ' 65 is ascii "A"
Upperalpha(count) = TALLY(MainString, any chr$(count+96)) ' 97 is ascii "a"

sMsg += CHR$(count+64) & " & " & CHR$(count+96) & $TAB
sMsg += " " & Loweralpha(count) & $TAB
sMsg += " " & Upperalpha(count) & $CRLF
next

MsgBox 0, sMsg

ErosOlmi
29-05-2007, 15:40
Thanks