CodePudding user response:
Press CTRL to open it, and see if it is to realize the,CodePudding user response:
In the original program1, press the CTRL key,
2, the mouse to click IntToStr,
One, open not SysUnit IntToStr method, is to rewrite IntToStr method, should be deleted,,
Two, open SysUnit IntToStr method, check whether agree with the following:
Value:
function IntToStr (Integer) : string;
//FmtStr (Result, '% d', [Value]);
Asm
PUSH ESI
MOV ESI, ESP
SUB ESP, 16
XOR ECX, ECX//base: 0 for signed decimal
PUSH the EDX//result PTR
XOR EDX, EDX//zero filled the field width: 0 for no leading zeros
CALL CvtInt
MOV EDX, ESI
POP EAX//result PTR
CALL System. @ LStrFromPCharLen
ADD the ESP, 16
POP ESI
The end;
Modified to run again,
Three, if invalid, only reinstall the,
CodePudding user response:
Upstairs, strtoint with inttostr don't mix well.
Before calling strtoint, can try their judgment, if character is a number [0.. 9]
Sometimes appear in character non-numeric characters, or numeric characters for whole Angle input, will go wrong.
CodePudding user response:
Sorry wrong,Advice before StrToInt function called by judgment, after execution:
Whether S plastic function:
function IsInteger (Str: string) : Boolean;//determine the integer
Var V, Code: Integer;
The begin
Val (Str, V, Code);
Result:=(Code=0) and (Pos (' X ', Str) & lt;=0);
The end;
Execute the code
"
if IsInteger (S) then I:=StrToInt (S)
My code, so, also avoids the error of digital characters,
CodePudding user response:
StrToInt in time for the incoming string is not a number, there are two methods, the use of the try... Except, capture process, or using TryStrToInt function,CodePudding user response: