unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls; type TForm1 = class(TForm) Panel1: TPanel; GroupBox1: TGroupBox; ScrollBar1: TScrollBar; StaticText1: TStaticText; StaticText2: TStaticText; Edit1: TEdit; StaticText3: TStaticText; BitBtn1: TBitBtn; BitBtn2: TBitBtn; BitBtn3: TBitBtn; GroupBox2: TGroupBox; Label1: TLabel; StatusBar1: TStatusBar; Label2: TLabel; Label3: TLabel; StaticText4: TStaticText; procedure ScrollBar1Change(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; current_value:word; division_counter:word; implementation {$R *.dfm} procedure TForm1.ScrollBar1Change(Sender: TObject); begin current_value:=ScrollBar1.Position; Edit1.Text:=IntToStr(current_value); end; procedure TForm1.BitBtn1Click(Sender: TObject); var i:word; kriterium:boolean; begin division_counter:=0; BitBtn1.Enabled:=false; kriterium:=true; for i:=2 to current_value-1 do begin if current_value mod i=0 then begin kriterium:=false; end; inc(division_counter); end; if kriterium=true then begin Label1.Caption:='JA'; Label2.Caption:=IntToStr(current_value); Label3.Caption:='ist eine Primzahl'; Label1.Font.Color:=clGreen; Label2.Font.Color:=clGreen; end else begin Label1.Caption:='NEIN'; Label2.Caption:=IntToStr(current_value); Label3.Caption:='ist keine Primzahl'; Label1.Font.Color:=clRed; Label2.Font.Color:=clRed; Label3.Font.Color:=clRed; end; Label1.Visible:=true; Label2.Visible:=true; Label3.Visible:=true; StatusBar1.Panels[1].Text:=IntToStr(division_counter); end; procedure TForm1.BitBtn2Click(Sender: TObject); begin Edit1.Text:='3'; ScrollBar1.Position:=3; Label1.Visible:=false; Label2.Visible:=false; Label3.Visible:=false; BitBtn1.Enabled:=true; StatusBar1.Panels[1].Text:='?'; end; end.