Форум по Delphi программированию

Delphi Sources



Вернуться   Форум по Delphi программированию > Все о Delphi > [ "Начинающим" ]
Ник
Пароль
Регистрация <<         Правила форума         >> FAQ Пользователи Календарь Поиск Сообщения за сегодня Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
  #1  
Старый 24.09.2011, 17:41
alena4227 alena4227 вне форума
Прохожий
 
Регистрация: 24.09.2011
Сообщения: 1
Репутация: 10
По умолчанию как сделать переменные локальными

Код:
unit lena42277777;

interface

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

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    StringGrid1: TStringGrid;
    StringGrid2: TStringGrid;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Edit11: TEdit;
    StringGrid3: TStringGrid;
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;a1,a2,a3,max:real;
c,r,max1,c1,r1:integer;
  a4,a5:real;


implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
StringGrid1.Cells[0,0]:='Prognoz firmi';
StringGrid1.Cells[1,0]:='Blagopriyatnij';
StringGrid1.Cells[2,0]:='NeBlagopriyatnij';
StringGrid1.Cells[0,1]:='Blagopriyatnij';
StringGrid1.Cells[0,2]:='NeBlagopriyatnij';
StringGrid1.Cells[3,0]:='Veroyatnoct';

StringGrid1.Cells[1,1]:='0,78';
StringGrid1.Cells[2,1]:='0,22';
StringGrid1.Cells[3,1]:='0,45';
StringGrid1.Cells[1,2]:='0,27';
StringGrid1.Cells[2,2]:='0,73';
StringGrid1.Cells[3,2]:='0,55';

StringGrid2.Cells[0,0]:='a1';
StringGrid2.Cells[1,0]:='a2';
StringGrid2.Cells[2,0]:='a3';
StringGrid3.Cells[1,0]:='Blagopriyatnij';
StringGrid3.Cells[2,0]:='NeBlagopriyatnij';
StringGrid3.Cells[0,1]:='a1';
StringGrid3.Cells[0,2]:='a2';
StringGrid3.Cells[0,3]:='a3';

Edit7.Text:='25000';

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
a1:=0.5*StrToInt(Edit1.text)+0.5* StrToInt(Edit4.text);
StringGrid2.Cells[1,1]:=FloatToStr(a1);
a2:=0.5*StrToInt(Edit2.text)+0.5* StrToInt(Edit5.text);
StringGrid2.Cells[2,1]:=FloatToStr(a2);
a3:=0.5*StrToInt(Edit3.text)+0.5* StrToInt(Edit6.text);
StringGrid2.Cells[3,1]:=FloatToStr(a3);

StringGrid3.Cells[1,1]:=FloatToStr(StrToInt(Edit1.text)*
 StrToFloat(StringGrid1.Cells[1,1])+StrToInt(Edit4.text)*
  StrToFloat(StringGrid1.Cells[2,1]));
StringGrid3.Cells[1,2]:=FloatToStr(StrToInt(Edit2.text)*
 StrToFloat(StringGrid1.Cells[1,1])+StrToInt(Edit5.text)*
  StrToFloat(StringGrid1.Cells[2,1]));
StringGrid3.Cells[1,3]:=FloatToStr(StrToInt(Edit3.text)*
 StrToFloat(StringGrid1.Cells[1,1])+StrToInt(Edit6.text)*
  StrToFloat(StringGrid1.Cells[2,1]));

StringGrid3.Cells[2,1]:=FloatToStr(StrToInt(Edit1.text)*
 StrToFloat(StringGrid1.Cells[1,2])+StrToInt(Edit4.text)*
 StrToFloat(StringGrid1.Cells[2,2]));
StringGrid3.Cells[2,2]:=FloatToStr(StrToInt(Edit2.text)*
 StrToFloat(StringGrid1.Cells[1,2])+StrToInt(Edit5.text)*
 StrToFloat(StringGrid1.Cells[2,2]));
StringGrid3.Cells[2,3]:=FloatToStr(StrToInt(Edit3.text)*
 StrToFloat(StringGrid1.Cells[1,2])+StrToInt(Edit6.text)*
  StrToFloat(StringGrid1.Cells[2,2]));

  end;
procedure TForm1.Button3Click(Sender: TObject);

begin
max:=0;
for c:=1 to StringGrid2.ColCount-1 do
for r:=1 to StringGrid2.RowCount-1 do
if StrToInt(StringGrid2.Cells[c,r])>max then max:=StrToInt(StringGrid2.Cells[c,r]);
Edit8.Text:=FloatToStr(max);
max1:=0;
for r1:=1 to StringGrid3.RowCount-1 do
if StrToInt(StringGrid3.Cells[1,r1])>max1 then max1:=StrToInt(StringGrid3.Cells[1,r1]);
a4:=max1;
Edit9.Text:=FloatToStr(a4);
max1:=0;
for r1:=1 to StringGrid3.RowCount-1 do
if StrToInt(StringGrid3.Cells[2,r1])>max1 then max1:=StrToInt(StringGrid3.Cells[2,r1]);
a5:=max1;
Edit10.Text:=FloatToStr(a5);
Edit11.Text:=FloatToStr(a4*StrToFloat(StringGrid1.Cells[3,1])+a5*StrToFloat(StringGrid1.Cells[3,2])-StrToInt(Edit7.Text));
if StrToFloat(Edit8.Text)> StrToFloat(Edit11.Text){max=StrToFloat(Edit8.Text)} then Memo1.Lines[0]:='Не стоит проводить дополнительные исследования,прибыль='+ Edit8.text
else Memo1.Lines[0]:='Стоит проводить дополнительные исследования,прибыль='+ Edit11.text;
end;

end. 

Почему не работает программа???как сделать переменные локальными?

Последний раз редактировалось lmikle, 24.09.2011 в 22:27.
Ответить с цитированием
 


Delphi Sources

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB-коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Часовой пояс GMT +3, время: 04:36.


 

Сайт

Форум

FAQ

Соглашения

Прочее

 

Copyright © Форум "Delphi Sources" by BrokenByte Software, 2004-2025