⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit2.pas.~56~

📁 《Delphi程序员成长攻略》-蒙祖强龚涛的源代码
💻 ~56~
字号:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, StdCtrls, DB, DBTables, ComCtrls;

type
  TForm2 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    Table1: TTable;
    UpDown1: TUpDown;
    Edit1: TEdit;
    Label1: TLabel;
    UpDown2: TUpDown;
    Edit2: TEdit;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Edit2Exit(Sender: TObject);
    procedure Edit1Exit(Sender: TObject);
    procedure UpDown2Click(Sender: TObject; Button: TUDBtnType);
    procedure FormCreate(Sender: TObject);
    procedure UpDown1Click(Sender: TObject; Button: TUDBtnType);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;  

implementation

{$R *.dfm}

procedure TForm2.UpDown1Click(Sender: TObject; Button: TUDBtnType);
begin

    Edit1.Text := IntToStr(UpDown1.Position);
    UpDown2.Position := 100-UpDown1.Position;
    Edit2.Text := IntToStr(UpDown2.Position);
end;

procedure TForm2.FormCreate(Sender: TObject);
begin

    Edit1.Text := IntToStr(UpDown1.Position);
    Edit2.Text := IntToStr(UpDown2.Position);

 
end;

procedure TForm2.UpDown2Click(Sender: TObject; Button: TUDBtnType);
begin
    Edit2.Text := IntToStr(UpDown2.Position);
    UpDown1.Position := 100-UpDown2.Position;
    Edit1.Text := IntToStr(UpDown1.Position); 
end;

procedure TForm2.Edit1Exit(Sender: TObject);
begin
    UpDown1.Position := StrToInt(Edit1.Text);
    UpDown2.Position := 100-UpDown1.Position;
    Edit2.Text := IntToStr(UpDown2.Position);
end;

procedure TForm2.Edit2Exit(Sender: TObject);
begin
    UpDown2.Position := StrToInt(Edit2.Text);
    UpDown1.Position := 100-UpDown2.Position;
    Edit1.Text := IntToStr(UpDown1.Position);
end;

procedure TForm2.Button1Click(Sender: TObject);
var pea_x,fin_x,ave_x:Real;
    pea_per,fin_per:integer;
begin
    table1.First;
    while not table1.Eof do
    begin
        Table1.Edit;
        pea_x := table1.FieldValues['pea_resu'];
        fin_x := table1.FieldValues['fin_resu'];
        pea_per := StrToInt(Edit1.Text);
        fin_per := StrToInt(Edit2.Text);
        ave_x := (pea_per/100.0)*pea_x + (fin_per/100.0)*fin_x;
        Table1.FieldByName('ave_resu').AsFloat := ave_x;
        Table1.Post;
        table1.Next;
 end;





end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -