Witam wszystkich .
Jestem bardzo zielony z delphi i proszę o pomoc.
Mam do napisania program o macierzach .
- Wyznaczanie wyznacznika macierzy 2x2
- Mnożenie macierzy przez liczbę.
3, Mnożenie macierzy przez wektor.
Program napisałem ale zatrzymałem sie w jednym miejscu
nie mogę opanować wyświetlania komuninkatów jeżeli nic nie wpisze w pola edit a jest ich 6
i do każdego ma sie wyświetlac inny dialogbox z errorem.
Próbowałem ale oprócz okna które chce uzyskać zaraz po nim jest okno "is not a integer value"
Oto mój kod programu:
unit Unit1;
interface
uses
Windows,Messages,SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
ComboBox1: TComboBox;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit4KeyPress(Sender: TObject; var Key: Char);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure Edit6KeyPress(Sender: TObject; var Key: Char);
procedure Edit7KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
if ( RadioButton2.Checked = True ) then begin
Edit5.Visible := False;
Edit6.Visible := False;
Edit7.Visible := True;
Edit8.Visible := True;
Edit9.Visible := True;
Edit10.Visible := True;
Edit11.Visible := True;
Label7.Visible := True;
Label2.Visible := False;
Label4.Visible := True;
Label3.Visible := True;
Label5.Visible := True;
Label6.Visible := True;
ComboBox1.Visible := True;
Edit8.Clear;
Edit9.Clear;
Edit10.Clear;
Edit11.Clear;
end;
end;
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
if ( RadioButton1.Checked = True ) then begin
Edit6.Visible := False;
Edit7.Visible := False;
Edit8.Visible := False;
Edit9.Visible := False;
Edit10.Visible := False;
Edit11.Visible := False;
Edit5.Visible := True;
Label5.Visible := False;
Label6.Visible := False;
Label4.Visible := False;
Label3.Visible := False;
Label2.Visible := True;
Label7.Visible := False;
ComboBox1.Visible := False
end;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
if (ComboBox1.ItemIndex = 1 ) then begin
Edit9.Visible := False;
Edit11.Visible := False;
Edit6.Visible:= True;
Edit8.Clear;
Edit10.Clear;
end;
if ( ComboBox1.ItemIndex = 0 ) then begin
Edit9.Visible := True;
Edit11.Visible := True;
EDit6.Visible := False;
Edit8.Clear;
Edit9.Clear;
Edit10.Clear;
Edit11.Clear;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
a,b,c,d : Integer;
w : Integer;
l,k : Integer;
f,g,h,i : Integer;
m,n : Integer;
begin
if ( RadioButton1.Checked = True ) then begin
a := StrToInt(Edit1.Text);
b := StrToInt(Edit2.Text);
c := StrToInt(Edit3.Text);
d := StrToInt(Edit4.Text);
w := (a*d)-(b*c);
Edit5.Text := IntToStr(w)
end;
if ( RadioButton2.Checked = True ) then Begin
a := StrToInt(Edit1.Text);
b := StrToInt(Edit2.Text);
c := StrToInt(Edit3.Text);
d := StrToInt(Edit4.Text);
l := StrToInt( Edit7.Text);
f := (a*l);
g := (b*l);
h := (c*l);
i := (d*l);
Edit8.Text := IntToStr(f);
Edit9.Text := IntToStr(g);
Edit10.Text := IntToStr(h);
Edit11.Text := IntToStr(i)
end;
if (ComboBox1.ItemIndex = 1 ) then begin
a := StrToInt(Edit1.Text);
b := StrToInt(Edit2.Text);
c := StrToInt(Edit3.Text);
d := StrToInt(Edit4.Text);
l := StrToInt(Edit7.Text);
k := StrToInt(Edit6.Text);
m :=(a+b)*k;
n :=(c+d)*l;
Edit8.Text := IntToStr(m);
Edit10.Text := IntToStr(n);
end;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9',#8,'-']) then Key:=#0;
end;
procedure TForm1.Edit4KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9',#8,'-']) then Key:=#0;
end;
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9',#8,'-']) then Key:=#0;
end;
procedure TForm1.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9',#8,'-']) then Key:=#0;
end;
procedure TForm1.Edit6KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9',#8,'-']) then Key:=#0;
end;
procedure TForm1.Edit7KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9',#8,'-']) then Key:=#0;
end;
end.
// to próbowałem zastosować:
// if Edit1.Text = '' then begin
// MessageBox(Handle,'Brak danych11 ','Macierze',MB_IconError);
// Edit1.SetFocus;
// a := StrToInt(Edit1.Text);
// end;
Przepraszam za mój język programowania ale dopiero zaczynam.