请教Delphi编程问题

来源:百度知道 编辑:UC知道 时间:2024/05/09 06:51:13
点击一个button1按扭把edit1-edit2范围内的所有质数添加到一个Listbox1中去
我刚开始学 不太会 有会的把代码都写上 谢谢

unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function IsPrime (N: LongInt): Boolean;
var
Test: LongInt;
begin
IsPrime := True;
for Test := 2 to N - 1 do
begin
if (N mod Test) = 0 then
begin
IsPrime := False;
break; {jump out of the for loop}
end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i,iBegin,iEnd:Integer;
begin
try