[code=thinbasic]
' 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
[/code]
Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370
Thanks
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Bookmarks