AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Calculate Min Max of integer

Ein Thema von nanix · begonnen am 2. Dez 2009 · letzter Beitrag vom 3. Dez 2009
 
nanix
(Gast)

n/a Beiträge
 
#1

Calculate Min Max of integer

  Alt 2. Dez 2009, 20:55
Hello how could i calculate this ... i was fooling around but still can't get it working here is what i got so far.
Basicly all values are the same MIN MAX VALUE

Delphi-Quellcode:
unit Unit3;

interface

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

type
  TForm3 = class(TForm)

    Button1: TButton;
    Timer1: TTimer;
    Button2: TButton;


    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


 type
  TMyInt = record
    FValue: Integer;
    FMin: Integer;
    FMax: Integer;
    FInit: Boolean;
  private
    procedure SetValue(const IntValue: Integer);
  public
    procedure Init;

    property Value: Integer read FValue write SetValue;
    property Min: Integer read FMin;
    property Max: Integer read FMax;
    end;

var
  Form3: TForm3;







implementation
{$R *.dfm}

procedure TMyInt.Init;
begin
  FInit := False;
end;

procedure TMyInt.SetValue(const IntValue: Integer);
begin
  if FValue <> IntValue then
    FValue := IntValue;

  if not FInit then
  begin
    FMax := FValue;
    FMin := FValue;
    FInit := True;
  end
  else
  begin
    if FValue > FMax then
      FMax := FValue;
    if FValue < FMin then
      FMin := FValue;
  end;
end;

// usage


procedure TForm3.Timer1Timer(Sender: TObject);
var
  temp: TMyInt;
begin
  temp.Init;
  temp.Value:=Random(100);
  form3.Caption:='Value '+inttostr(Temp.Value)+' Min '+inttostr(temp.Min)+' Max '+inttostr(temp.Max);

end;

end.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:17 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz