100分够吗?求高手修改一下代码,我的窗体里有两个按钮,一个开始,一个关闭窗体,当我点击了开始,程序就停止不了了,根本按不了关闭窗体这个按钮,谁能帮我改改啊?发到我邮箱里吧!![email protected]我的代码是:unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;  const
  mystring: array [0..11] of string=('a','b','c','d','e','f','4','5','6','7','8','9');                                     
type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
  i,j,k,l: integer;
begin
  memo1.lines.clear;
  for i:=0 to 11 do
    for j:=0 to 11 do
      for k:=0 to 11 do
        for l:=0 to 11 do
          memo1.lines.add(mystring[i]+mystring[j]+mystring[k]+mystring[l]);
  memo1.lines.savetofile('c:\wl.txt');
end;procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;end.

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;  const
      mystring: array [0..11] of string=('a','b','c','d','e','f','4','5','6','7','8','9');                                     
    type
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      i,j,k,l: integer;
    begin
      memo1.lines.clear;
      for i:=0 to 11 do
        for j:=0 to 11 do
          for k:=0 to 11 do
            for l:=0 to 11 do
              memo1.lines.add(mystring[i]+mystring[j]+mystring[k]+mystring[l]);
              Application.ProcessMessages ;
      memo1.lines.savetofile('c:\wl.txt');
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
    close;
    end;end.
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      i,j,k,l: integer;
    begin
      memo1.lines.clear;
      for i:=0 to 11 do
        for j:=0 to 11 do
          for k:=0 to 11 do
            for l:=0 to 11 do
              memo1.lines.add(mystring[i]+mystring[j]+mystring[k]+mystring[l]);
              Application.ProcessMessages ;
       memo1.lines.savetofile('c:\wl.txt');
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
    close;
    end;end.
      

  3.   

    begin
      memo1.lines.clear;
      for i:=0 to 11 do
        for j:=0 to 11 do
          for k:=0 to 11 do
            for l:=0 to 11 do
            begin
                memo1.lines.add(mystring[i]+mystring[j]+mystring[k]+mystring[l]);
      memo1.lines.savetofile('c:\wl.txt');
                Application.ProcessMessages; 
            end;
              
    end;
      

  4.   

    呵呵,在button1的代码里面做一个判断吧:)
      

  5.   

    看看我的测试代码
    var
      bExit:boolean;
    procedure TForm1.Button1Click(Sender: TObject);
    var
      i,j,k,l: integer;
    begin
      for i:=0 to 11 do
        for j:=0 to 11 do
          for k:=0 to 11 do
            for l:=0 to 11 do
            begin
              if bExit then exit;
              caption:=inttostr(i+j+k+l);
              application.ProcessMessages;
            end;
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      bExit:=true;
      close;
    end;
    要不你用一个线程来处理长时间的循环也可以
      

  6.   

    foxyy8888(大漠孤烟弯,长河落日扁。) , lincanwen(密码错误) ,两位大侠的代码不好用啊!!!