?? elec_2.~pas
字號:
StringGrid3.Cells[j,row_select+1]:=floattostr(Y[j,row_select+1]);
StringGrid3.Cells[row_select+1,j]:=floattostr(Y[row_select+1,j]);
StringGrid3.Cells[k,row_select+1]:=floattostr(Y[k,row_select+1]);
StringGrid3.Cells[row_select+1,k]:=floattostr(Y[row_select+1,k]);
{常數矩陣顯示}
StringGrid5.Cells[1,SpinEdit1.Value]:=floattostr(B[SpinEdit1.Value]);
end
else
showmessage('數組下標越界,重新輸入節點標號');
end;
{電流控制電流源}
procedure TForm1.N51Click(Sender: TObject);
var
u,v,w,z,h:integer;
begin
StringGrid2.Cells[6,row_select]:= N51.Caption;
if TryStrToInt(trim(StringGrid2.Cells[1,row_select]),u) then {取下標}
j:=u
else
showmessage('節點J標號置入錯誤,重新輸入節點J標號');
if TryStrToInt(trim(StringGrid2.Cells[2,row_select]),v) then
k:=v
else
showmessage('節點K標號置入錯誤,重新輸入節點K標號');
if TryStrToInt(trim(StringGrid2.Cells[3,row_select]),w) then {取下標}
f:=w
else
showmessage('節點F標號置入錯誤,重新輸入節點F標號');
if TryStrToInt(trim(StringGrid2.Cells[4,row_select]),z) then
t:=z
else
showmessage('節點T標號置入錯誤,重新輸入節點T標號');
if TryStrToInt(trim(StringGrid2.Cells[5,row_select]),z) then
m:=h
else
showmessage('數據M置入錯誤,重新輸入數據M');
if (k < SpinEdit1.Value+4) and (j < SpinEdit1.Value+4) then
begin
Y[j,f]:=Y[j,f]+(D[row_select-1]*D[m-1]);
Y[j,t]:=Y[j,t]-(D[row_select-1]*D[m-1]);
Y[k,f]:=Y[k,f]-(D[row_select-1]*D[m-1]);
Y[k,t]:=Y[k,t]+(D[row_select-1]*D[m-1]);
StringGrid3.Cells[j,f]:=floattostr(Y[j,f]);
StringGrid3.Cells[j,t]:=floattostr(Y[j,t]);
StringGrid3.Cells[k,f]:=floattostr(Y[k,f]);
StringGrid3.Cells[k,t]:=floattostr(Y[k,t]);
end
else
showmessage('數組下標越界,重新輸入節點標號');
end;
{電壓控制電流源}
procedure TForm1.N4Click(Sender: TObject);
var
u,v,w,z:integer;
begin
StringGrid2.Cells[6,row_select]:= N4.Caption ;
if TryStrToInt(trim(StringGrid2.Cells[1,row_select]),u) then {取下標}
j:=u
else
showmessage('節點J標號置入錯誤,重新輸入節點J標號');
if TryStrToInt(trim(StringGrid2.Cells[2,row_select]),v) then
k:=v
else
showmessage('節點K標號置入錯誤,重新輸入節點K標號');
if TryStrToInt(trim(StringGrid2.Cells[3,row_select]),w) then {取下標}
f:=w
else
showmessage('節點F標號置入錯誤,重新輸入節點F標號');
if TryStrToInt(trim(StringGrid2.Cells[4,row_select]),z) then
t:=z
else
showmessage('節點T標號置入錯誤,重新輸入節點T標號');
if (k < SpinEdit1.Value+4) and (j < SpinEdit1.Value+4) then
begin
Y[j,f]:=Y[j,f]+D[row_select-1];
Y[j,t]:=Y[j,t]-D[row_select-1];
Y[k,f]:=Y[k,f]-D[row_select-1];
Y[k,t]:=Y[k,t]+D[row_select-1];
StringGrid3.Cells[j,f]:=floattostr(Y[j,f]);
StringGrid3.Cells[j,t]:=floattostr(Y[j,t]);
StringGrid3.Cells[k,f]:=floattostr(Y[k,f]);
StringGrid3.Cells[k,t]:=floattostr(Y[k,t]);
end
else
showmessage('數組下標越界,重新輸入節點標號');
end;
{電壓源中電流控制電流源}
procedure TForm1.N61Click(Sender: TObject);
var
u,v:integer;
begin
StringGrid2.Cells[6,row_select]:= N61.Caption;
if TryStrToInt(trim(StringGrid2.Cells[1,row_select]),u) then {取下標}
j:=u
else
showmessage('節點J標號置入錯誤,重新輸入節點J標號');
if TryStrToInt(trim(StringGrid2.Cells[2,row_select]),v) then
k:=v
else
showmessage('節點K標號置入錯誤,重新輸入節點K標號');
if (k < SpinEdit1.Value+4) and (j < SpinEdit1.Value+4) then
begin
Y[j,row_select+1]:=Y[j,row_select+1]+D[row_select-1];
Y[k,row_select+1]:=Y[k,row_select+1]-D[row_select-1];
StringGrid3.Cells[j,row_select+1]:=floattostr(Y[j,row_select+1]);
StringGrid3.Cells[k,row_select+1]:=floattostr(Y[k,row_select+1]);
end
else
showmessage('數組下標越界,重新輸入節點標號');
end;
{電壓源控制電壓源}
procedure TForm1.N71Click(Sender: TObject);
var
u,v,w,z:integer;
begin
StringGrid2.Cells[6,row_select]:= N71.Caption;
if TryStrToInt(trim(StringGrid2.Cells[1,row_select]),u) then {取下標}
j:=u
else
showmessage('節點J標號置入錯誤,重新輸入節點J標號');
if TryStrToInt(trim(StringGrid2.Cells[2,row_select]),v) then
k:=v
else
showmessage('節點K標號置入錯誤,重新輸入節點K標號');
if TryStrToInt(trim(StringGrid2.Cells[3,row_select]),w) then {取下標}
f:=w
else
showmessage('節點F標號置入錯誤,重新輸入節點F標號');
if TryStrToInt(trim(StringGrid2.Cells[4,row_select]),z) then
t:=z
else
showmessage('節點T標號置入錯誤,重新輸入節點T標號');
if (k < SpinEdit1.Value+4) and (j < SpinEdit1.Value+4)then
begin {對系數矩陣賦值}
Y[j,row_select+2]:=1;
Y[k,row_select+2]:=-1;
Y[row_select+2,j]:=1;
Y[row_select+2,k]:=-1;
Y[row_select+2,f]:=Y[row_select+2,f]-D[row_select-1];
Y[row_select+2,t]:=Y[row_select+2,t]+D[row_select-1];
StringGrid3.Cells[j,row_select+2]:=floattostr(Y[j,row_select+2]);
StringGrid3.Cells[k,row_select+2]:=floattostr(Y[k,row_select+2]);
StringGrid3.Cells[row_select+2,j]:=floattostr(Y[row_select+2,j]);
StringGrid3.Cells[row_select+2,k]:=floattostr(Y[row_select+2,k]);
StringGrid3.Cells[row_select+2,f]:=floattostr(Y[row_select+2,f]);
StringGrid3.Cells[row_select+2,t]:=floattostr(Y[row_select+2,t]);
end
else
showmessage('數組下標越界,重新輸入節點標號');
end;
{電流源控制電壓源}
procedure TForm1.N81Click(Sender: TObject);
var
u,v,w,z,h:integer;
begin
StringGrid2.Cells[6,row_select]:= N81.Caption ;
if TryStrToInt(trim(StringGrid2.Cells[1,row_select]),u) then {取下標}
j:=u
else
showmessage('節點J標號置入錯誤,重新輸入節點J標號');
if TryStrToInt(trim(StringGrid2.Cells[2,row_select]),v) then
k:=v
else
showmessage('節點K標號置入錯誤,重新輸入節點K標號');
if TryStrToInt(trim(StringGrid2.Cells[3,row_select]),w) then {取下標}
f:=w
else
showmessage('節點F標號置入錯誤,重新輸入節點F標號');
if TryStrToInt(trim(StringGrid2.Cells[4,row_select]),z) then
t:=z
else
showmessage('節點T標號置入錯誤,重新輸入節點T標號');
if TryStrToInt(trim(StringGrid2.Cells[5,row_select]),z) then
m:=h
else
showmessage('數據M置入錯誤,重新輸入數據M');
if (k < SpinEdit1.Value+4) and (j < SpinEdit1.Value+4)then
begin
Y[j,row_select+3]:=1;
Y[k,row_select+3]:=-1;
Y[row_select+3,j]:=1;
Y[row_select+3,k]:=-1;
Y[row_select+3,f]:=Y[row_select+3,f]-(D[row_select-1]*D[m-1]);
Y[row_select+3,t]:=Y[row_select+3,t]+(D[row_select-1]*D[m-1]);
StringGrid3.Cells[j,row_select+3]:=floattostr(Y[j,row_select+3]);
StringGrid3.Cells[k,row_select+3]:=floattostr(Y[k,row_select+3]);
StringGrid3.Cells[row_select+3,j]:=floattostr(Y[row_select+3,j]);
StringGrid3.Cells[row_select+3,k]:=floattostr(Y[row_select+3,k]);
StringGrid3.Cells[row_select+3,f]:=floattostr(Y[row_select+3,f]);
StringGrid3.Cells[row_select+3,t]:=floattostr(Y[row_select+3,t]);
end
else
showmessage('數組下標越界,重新輸入節點標號');
end;
{電壓源中電流源控制電壓源}
procedure TForm1.N91Click(Sender: TObject);
var
u,v:integer;
begin
StringGrid2.Cells[6,row_select]:= N91.Caption ;
if TryStrToInt(trim(StringGrid2.Cells[1,row_select]),u) then {取下標}
j:=u
else
showmessage('節點J標號置入錯誤,重新輸入節點J標號');
if TryStrToInt(trim(StringGrid2.Cells[2,row_select]),v) then
k:=v
else
showmessage('節點K標號置入錯誤,重新輸入節點K標號');
if (k < SpinEdit1.Value+4) and (j < SpinEdit1.Value+4) then
begin
Y[j,row_select+4]:=1;
Y[k,row_select+4]:=-1;
Y[row_select+4,j]:=1;
Y[row_select+4,k]:=-1;
Y[row_select+4,row_select+1]:=Y[row_select+4,row_select+1]-D[row_select-1];
StringGrid3.Cells[j,row_select+4]:=floattostr(Y[j,row_select+4]);
StringGrid3.Cells[k,row_select+4]:=floattostr(Y[k,row_select+4]);
StringGrid3.Cells[row_select+4,j]:=floattostr(Y[row_select+4,j]);
StringGrid3.Cells[row_select+4,k]:=floattostr(Y[row_select+4,k]);
StringGrid3.Cells[row_select+4,row_select+1]:=floattostr(Y[row_select+4,row_select+1]);
end
else
showmessage('數組下標越界,重新輸入節點標號');
end;
procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
var
v:double;
begin
if tryStrToFloat(value,v) then
D[ACol]:= v
else
begin
StringGrid1.Cells[ACol,ARow]:=value;
if StringGrid1.Cells[ACol,ARow]<>'' then
showmessage('錄入數據非法');
D[ACol]:= 0;
end;
end;
procedure TForm1.StringGrid2SetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
VAR
V:integer;
begin
if not TryStrToInt(value,v) then
begin
StringGrid2.Cells[ACol,ARow]:=value;
if StringGrid2.Cells[ACol,ARow]<>'' then
showmessage('錄入數據非法');
end;
end;
procedure TForm1.StringGrid5SetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
var
v:double;
begin
if not tryStrToFloat(value,v) then
begin
StringGrid5.Cells[ACol,ARow]:=value;
if StringGrid5.Cells[ACol,ARow]<>'' then
showmessage('錄入數據非法');
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
showmessage(floattostr(D[1]));
{ showmessage(floattostr(Y[1,1])); }
end;
procedure TForm1.Button4Click(Sender: TObject);
var
aa:integer;
begin
SpinEdit1.Value:=0;
{清空賦值表格}
with StringGrid1 do
for aa := 0 to ColCount - 1 do
Cols[aa].Clear;
stringgrid1.ColCount:= 1;
stringgrid1.RowCount:= 1;
{清空數據置入表格}
with StringGrid2 do
for aa := 0 to ColCount - 1 do
Cols[aa].Clear;
stringgrid2.RowCount:= 1;
stringgrid2.ColCount:= 1;
{清空矩陣表格}
with StringGrid3 do
for aa := 0 to ColCount - 1 do
Cols[aa].Clear;
stringgrid3.ColCount:= 1;
stringgrid3.RowCount:= 1;
{清空結果數據表格}
with StringGrid4 do
for aa := 0 to ColCount - 1 do
Cols[aa].Clear;
stringgrid4.ColCount:= 1;
stringgrid4.RowCount:= 1;
{清空數據置入表格}
with StringGrid5 do
for aa := 0 to ColCount - 1 do
Cols[aa].Clear;
stringgrid5.ColCount:= 1;
stringgrid5.RowCount:= 1;
{清空各數組}
Y:=nil;
B:=nil;
X:=nil;
D:=nil;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -