How to convert a number printed in a string into integer?
Thank you.
The is procedure Val:
procedure Val(S; var V; var Code: Integer);
This procedure operate on decimal and real numbers.
Parmeters:
Use cases:
Var Value :Integer;
Val('1234', Value, Code); // Value = 1234, Code = 0
Val('1.234', Value, Code); // Value = 0, Code = 2
Val('abcd', Value, Code); // Value = 0, Code = 1
You can use Val function.
Example:
var
sNum: String;
iNum: Integer;
code: Integer;
begin
s := '101';
Val(s, iNum, code);
end.
You want Val()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With