var i:Integer; begin if TryStrToInt(edt1.Text,i) then // else // end;
to wing_er:TryStrToInt(edt1.Text,i)这个是什么函数,我在帮助里怎么没找到?可否说的具体一点,谢谢!to jz:我是在onKeyPress事件中只允许输入0-9这十个数。
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not(Key in ['0'..'9', Char(VK_BACK)]) then Key := #0; end;
Edit 的OnExit事件: try StrToInt((Sender as TEdit).Text); except //Showmessage('Error'); end;
sysutilsfunction TryStrToInt(const S: string; out Value: Integer): Boolean; var E: Integer; begin Val(S, Value, E); Result := E = 0; end;------------- http://bbs.im56.com
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not(Key in ['0'..'9', Char(VK_BACK)]) then Key := #0; end;用楼上这个。这个是在用户按键盘的时候就拦截验证,只能输入0-9的数字。和删除退格键。
i:Integer;
begin
if TryStrToInt(edt1.Text,i) then
//
else
//
end;
begin
if not(Key in ['0'..'9', Char(VK_BACK)]) then Key := #0;
end;
try
StrToInt((Sender as TEdit).Text);
except
//Showmessage('Error');
end;
var
E: Integer;
begin
Val(S, Value, E);
Result := E = 0;
end;-------------
http://bbs.im56.com
strtoint(edit1.text)
except
showmessage('该处必须输入整数!')
end;
StrToInt(Edit1.Text);
except
Showmessage('Input Error');
end;
begin
if not(Key in ['0'..'9', Char(VK_BACK)]) then Key := #0;
end;用楼上这个。这个是在用户按键盘的时候就拦截验证,只能输入0-9的数字。和删除退格键。