procedure TForm1.Button1Click(Sender: TObject);
begin
try
if StrToInt(Edit1.Text) > StrToInt(Edit2.Text) then
begin
ShowMessage('Edit1的值不可大于Edit2的值');
Edit2.Text:='';
Edit2.SetFocus;
end
else
begin
ShowMessage('条件符合规则,可以继续运行');
end;
except
On e:Exception do
begin
ShowMessage('Edit1和Edit2只能输入纯数字');
Edit2.Text:='';
Edit2.SetFocus;
end;
end;
end;
解决方案 »
- 三层向导问题?
- 寻找一表格控件
- #号后面跟一些数字表示什么?比如#255
- 如何获取数据库中数据表的个数和数据表的名称,,,,急
- 请问这两个数有什么关关系,如下,thanks
- delphi2010 Rtti 能不能取得某单元的某个函数
- 请问各位大侠,现在用SQL SERVER2000的企业管理器登陆数据库是不用密码的,如何设置才能使每次的登陆都要经过密码验证呢?谢谢!!
- 什么办??
- 自编函数:处理中文日期 、处理BDE数据库别名、查找目录文件...
- 如何在一个NT的Service中封装一个RemoteDataModule?
- XE5中对DBGridEh控件添加属性的问题
- delphi7安装了ehlib 但是软件每次重启后,都要手动加载一下。
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Function StrYesFloat(S:string):boolean; // 检查字符串是Float字符 end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var S1,S2:string;
begin
S1:=Edit1.Text;
S2:=Edit2.Text;
if Not StrYesFloat(S1) then
begin
ShowMessage('"数据1"含有无效字符,请重新录入!');
exit;
end;
if Not StrYesFloat(S2) then
begin
ShowMessage('"数据2"含有无效字符,请重新录入!');
exit;
end;
if StrToFloat(S1)<StrToFloat(S2) then
begin
ShowMessage('"数据1"不能小于"数据2",请重新录入数据!');
Exit;
end;
// 下一步操作代码....
ShowMessage('OK!');
end;procedure TForm1.FormShow(Sender: TObject);
begin
Edit1.text:='';
Edit2.text:='';
end;Function TForm1.StrYesFloat(S:string):boolean; // 检查字符串是Float字符
var I,J,K:integer;
T:boolean;
begin
T:=True;
result:=False;
J:=0;
K:=0;
if Copy(S,1,1)='-' then S:=Copy(S,2,length(S)-1); // 首位字符- 负数有效
for I:=1 to Length(S) do
begin
if not ((Ord(S[i])>=46) and (Ord(S[i])<=57) and (Ord(S[i])<>47)) then T:=False;
if (Ord(S[i])>=48) and (Ord(S[i])<=57) then J:=J+1;
if Ord(S[i])=46 then K:=K+1;
end;
if T then
if J>0 then
if K<2 then
result:=True;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;end.