dlephi程序流程一(if then)

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    stredit: TEdit;
    btn1: TButton;
    procedure btn1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure streditKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
implementation
{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject); //窗体创建完毕
begin
     SetWindowLong(stredit.Handle,
     GWL_STYLE,
     GetWindowLong(stredit.Handle, GWL_STYLE) or ES_CENTER);
     stredit.Refresh;    //子类化编辑框 让数字在中间
end;

procedure TForm1.streditKeyPress(Sender: TObject; var Key: Char);
//编辑框输入事件
//添加事件 组件事件在EVENTS面版里在事件名字后面的空白处双击2下就可以添加
begin
      //if not(key in['0'..'9',#8])then
      //key:=#0;    //限制只能输入数字 退格键   方法一
      if  (not (key in['0'..'9'])) and (Key <>#8) then
      key:=#0;      //限制只能输入数字  退格键  方法二
end;

procedure TForm1.btn1Click(Sender: TObject); //按钮单击事件
var s:Integer;
begin

      s:=StrToInt(stredit.Text);
      ShowMessage(stredit.Text);
      if (s=100) or (s=10000) then
      MessageBoxa(0,'输入了100或输入了1000','shellcode',0);
end;
end.

 

 

posted on 2013-06-18 12:18  shellcode  阅读(253)  评论(0编辑  收藏  举报

导航