|
Assume
Label control is Label1
Text box control is Text1
Statistics button control is Command1
Exit button control is Command2
Create a Prg and name it MyFunc.Prg.
FUNCTION StrIdentify
LPARAMETERS lcString
LOCAL lc Chinese, ln Chinese, lc English, ln English, lc space, ln space number, lc number, ln number, lc other characters, ln other characters
STORE '' TO lc Chinese, lc English, lc space, lc number, lc other characters
STORE 0 TO ln Chinese number, ln English number, ln space number, ln number number, ln other characters number
FOR I = 1 TO LEN (lcString)
IF ISLEADBYTE (SUBSTR (lcString, I, 1))&&Chinese (Chinese and Chinese symbols are double-byte)
lcChinese = lcChinese + SUBSTR (lcString, I, 2)
I = I + 1
ln Chinese number = ln Chinese number +1
LOOP
ELSE
DO CASE
CASE UPPER (SUBSTR (lcString, I, 1)) $ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
lcEnglish = lcEnglish + SUBSTR (lcString, I, 1)
ln English number = ln English number + 1
CASE SUBSTR (lcString, I, 1) = SPACE (1)
lc space = lc space + SUBSTR (lcString, I, 1)
ln spaces = ln spaces + 1
CASE SUBSTR (lcString, I, 1) $ '1234567890'
lc number = lc number + SUBSTR (lcString, I, 1)
number of ln numbers = number of ln numbers + 1
OTHERWISE
lc other characters = lc other characters + SUBSTR (lcString, I, 1)
ln other characters = ln other characters + 1
ENDCASE
ENDIF
ENDFOR
lcRetVal = 'Chinese (including Chinese symbols):' + ALLTRIM (STR (ln Chinese number)) + '. Yes: "'+ lc 中文 +'" '
lcRetVal = lcRetVal + CHR (10) + 'English letters:' + ALLTRIM (STR (ln English number)) + '. Yes: "'+ lcEnglish +'" '
lcRetVal = lcRetVal + CHR (10) + 'spaces:' + ALLTRIM (STR (number of ln spaces)) + '. Yes: "'+ lcspace +'" '
lcRetVal = lcRetVal + CHR (10) + 'Numbers:' + ALLTRIM (STR (number of ln numbers)) + '. Yes: "'+ lcdigit +'" '
lcRetVal = lcRetVal + CHR (10) + 'Other characters:' + ALLTRIM (STR (ln other characters)) + '. Yes: "'+ lc other characters +'" '
RETURN lcRetVal
ENDFUNC
then
Load event of the form:
Set Proc To MyFunc.Prg
Form's Unload event:
Set Proc to
Command1's Click event:
THISFORM.LABEL1.CAPTION = StrIdentify (THISFORM.TEXT1.VALUE)
MESSAGEBOX (StrIdentify (THISFORM.TEXT1.VALUE))
Command2's Click event:
Thisform.Release
In addition, set the width and height of Label1 to be larger so that the results can be displayed in full. |
|