Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What's the difference between trystrtoint and strtoint in delphi7? Don't they all convert strings into shapes?
What's the difference between trystrtoint and strtoint in delphi7? Don't they all convert strings into shapes?
strtoint

Is to directly convert the int function or get an integer.

But if the conversion fails, you will get an exception.

trystrtoint

That is, get a Boolean value, judge whether the conversion is successful according to the Boolean value, and then judge whether to fetch data.

defined variable

S: string;

I: integer;

s:= ' 1 1 1 1A ';

If it is not trystroint (s, i), then

begin

ShowMessage ('Conversion failed!' );

end

other

begin

ShowMessage ('converted successfully, the result is'++inttostr(I)););

End;