| |

VerySource

 Forgot password?
 Register
Search
View: 679|Reply: 2

Help vfp form design

[Copy link]

2

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-2 13:40:02
| Show all posts |Read mode
Use the text box and label controls to design a form Test.scx, and use it to count the total number of characters and the number of letters.
Claim. 1. Click "Statistics" button to start counting characters
      2. Click the "Exit" button to end the running of the program
The number of characters counted is displayed like this
  Total number of characters entered ------
  The number of letters ------

Every strongman, write the code in the button to the younger brother, look at it! !!
Reply

Use magic Report

0

Threads

32

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-3-24 19:30:01
| Show all posts
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.
Reply

Use magic Report

2

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-3-25 14:15:01
| Show all posts
Thank you! !! !! !!
vf is really troublesome
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list