看看我的程序为何不运行了
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    ListBox1: TListBox;
    procedure FormCreate(Sender:TObject);
    procedure Edit1Exit(Sender:TObject);
    procedure Button1Click(Sender:TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender:TObject);
begin
        Form1.Edit1.Text:='';
        Form1.ListBox1.Clear();
        Form1.Button1.Enabled:=false;
end;procedure TForm1.Edit1Exit(Sender:TObject);
begin
        if(Form1.Edit1.Text='') then
        begin
                Showmessage('请输入学号');
                Form1.Edit1.SetFocus();
                Form1.Button1.Enabled:=false;
                exit;
        end;
        if(StrToInt(Form1.Edit1.Text)<0) then
        begin
                Showmessage('输入的学号不正确');
                Form1.Edit1.SetFocus();
                Form1.Button1.Enabled:=false;
                exit;
        end;
        Form1.Button1.Enabled:=true;
end;procedure TForm1.Button1Click(Sender:TObject);
var
        xuehao:integer;
begin
        xuehao:=StrToInt(Form1.Edit1.Text);
        Form1.ListBox1.Clear();
        case xuehao of
                950255:
                begin
                        Form1.ListBox1.Items.Add('姓名:刘志');
                        Form1.ListBox1.Items.Add('年龄:19');
                        Form1.ListBox1.Items.Add('性别:男');
                        Form1.ListBox1.Items.Add('院系:大连理工大学');
                        Form1.ListBox1.Items.Add('备注:辽宁人,性格豪爽');
                        exit;
                end;
                else
                begin
                        Showmessage('没有找到此学生信息');
                end;
        end;
end;
end.

解决方案 »

  1.   

    procedure TForm1.Edit1Exit(Sender:TObject);  //不要滥用Exit事件
    begin
            if(Form1.Edit1.Text='') then
            begin
                    Showmessage('请输入学号');
                    Form1.Edit1.SetFocus();
                    Form1.Button1.Enabled:=false;
                    exit;
            end;
            if(StrToInt(Form1.Edit1.Text)<0) then
            begin
                    Showmessage('输入的学号不正确');
                    Form1.Edit1.SetFocus();
                    Form1.Button1.Enabled:=false;
                    exit;
            end;
            Form1.Button1.Enabled:=true;
    end;
    你的程序可以运行,关键是你没搞清楚Exit事件。你输入了学号后,点一下ListBox,就运行了。
      

  2.   

    procedure TForm1.Edit1Exit(Sender:TObject);  
    这个事件似乎用不恰当,你要用这个事件来表示什么,判断吗。
    你应该用onkey事件好一点吧。当按回车的时候判断
      

  3.   

    你的程序我帮你调过,没有太大的问题,你说没有反应,是因有你没有做这方面的代码!!所以。,。。,还没有你没有连接数据库,只有一个学号才是对你,还有当你在eidt1中输入学号后,然后单击listbox1,button1在可以用,这点设计的不是太好!!其它的我也看不出来是什么问题!!你要的结果没有出来,你可以单步执行看看,哪个地方没有用到,或者哪能个地方有问题!!!