Pozdrav
reikonija, vidi ovo (
link):
Code:
// Example code : Catching string to integer conversion errors
var
A : Integer;
begin
// We will catch conversion errors
try
A := StrToInt('100 '); // Trailing blanks are not supported
except
on Exception: EConvertError do
ShowMessage(Exception.Message);
end;
try
A := StrToInt('$FG'); // 'G' is an invalid hexadecimal digit
except
on Exception : EConvertError do
ShowMessage(Exception.Message);
end;
end;
Ako hoces da budes siguran da je u pitanju stvarno broj (integer), mozes uraditi nesto ovako ne bi li iz poruke izbacio sve znake koji nisu brojevi:
Code:
var
i : integer;
sBroj: string;
begin
sBroj := '';
if (Edit1.Text <> '') then
begin
for i := 1 to Length(Edit1.Text) do
begin
if Edit1.Text[i] in ['0'..'9'] then sBroj := sBroj + Edit1.Text[i];
end;
Edit1.Text := sBroj;
end;
end;
[Ovu poruku je menjao ((BugA)) dana 25.09.2011. u 07:27 GMT+1]