unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
Tfrminput = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Button1: TButton;
Button2: TButton;
edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
{입력 자료 형식 정의}
type Tinput=record
dep_code:string;//부서코드
in_num :string; //시내통화량
out1_num : string;//시외 1대역 통화량
out2_num: string; //시외 2대역 통화량
method:string//결재코드
end;
{출력 자료 형식 정의}
type Toutput=record
dep_name:string;//부서명
call_num:string;//전화번호
in_value:integer;//시내통화금액
out_value:integer;//시외통화금액
tax:integer;//세금
total_value:integer;//통화총액
etc:string //비고
end;
var
frminput: Tfrminput;
{프로그램 전역변수선언}
count:integer;
in_data:array[1..7] of tinput ; //입력자료배열선언
out_data:array[1..7] of toutput; //출력자료 배열선언
implementation
uses unit2;
{$R *.DFM}
{입력버튼이 눌렸을 경우 실행되는 함수}
procedure Tfrminput.Button1Click(Sender: TObject);
var
i,discount,ou1,out2,call_value:integer;//루프용변수
disrate:real;
begin
{최대 입력건수는 7건이하로 간주한다.}
if count>7 then
showmessage('최대입력건수를 초과하였습니다.');
exit;
end;
if count >= 2 then
for i:=1 to count-1 do
if uppercase(in_data[i].dep_code) = uppercase(edit1.text) then
begin
showmessage('부서코드가 중복되었습니다.');
edit1.text:='';
edit1.setfocus;
exit;
end;
with Out_data[count] do
begin
{부서명과 전화번호를 구한다.}
if uppercase(edit1.text)='A' then
begin
dep_name:='총무부';
call_num:='940-8857';
end
else if uppercase(edit1.text)='B' then
begin
dep_name:='인사부';
call_num:='940-6589';
end
else if uppercase(edit1.text)='C' then
begin
dep_name:='영업1부';
call_num:='940-7740';
end
else if uppercase(edit1.text) ='D' then
begin
dep_name:='영업2부';
call_num:='940-5212';
end
else if uppercase(edit1.text) ='E' then
begin
dep_name:='영업3부';
call_num:='940-6320';
end
else
begin
showmessage('부서코드 입력 오류입니다.!');
edit1.text:='';
edit1.setfocus;
exit;
end;
{시내통화량을 입력한다. 단,3자리 이하의 정수로 입력}
if (edit2.text<>'') and (edit2.text>0) and (edit2.text<=999) then
begin
in_value := 50*edit2.text;
end
else
begin
showmessage('시내 통화량 입력오류!!');
edit2.text:='';
edit2.setfocus;
exit;
end;
{시외1대역 통화량과 시외 2대역 통화량을 3자리 이하의 정수로 입력}
if (edit3.text<>'') and (edit3.text>0) and (edit3.text<=999) then
begin
out1 := edit3.text;
end
else
begin
showmessage('시외 1대역 통화량 입력오류!!');
edit3.text:='';
edit3.setfocus;
exit;
end;
if (edit4.text<>'') and (edit4.text>0) and (edit4.text<=999) then
begin
out2 := edit4.text;
end
else
begin
showmessage('시외 1대역 통화량 입력오류!!');
edit4.text:='';
edit4.setfocus;
exit;
end;
out_value:= (out1*80)+(out2*120);
{결재코드표에 따른 할인률입력}
if uppercase(edit5.text)='PA' then
begin
disrate := 0;
end
else if uppercase(edit5.text)='PB' then
begin
disrate := 0.02;
end
else if uppercase(eidt5.text)='PC' then
begin
disrate := 0.05;
end;
call_value:=in_value+out_value+3000;
tax:=call_value*0.1;
discount:=call_value+tax*disrate;
total_value:=(call_value+tax+3000)-discount;
if (total_value<=30000) then
begin
etc:='절약';
end
else
begin
etc:='';
exit;
end;
{입력배열에 자료 저장}
with in_data[count] do
begin
dep_code :=edit1.text;
in_num :=edit2.text;
out1_num :=edit3.text;
out2_num :=edit4.text;
method :=edit5.text;
end;
{입력을 초기화}
edit1.text:='';
edit2.text:='';
edit3.text:='';
edit4.text:='';
edit5.text:='';
edit1.setfocus;
inc(count);
end;
{출력버튼이 눌렸을때 처리되는 함수}
procedure Tfrminput.Button2Click(Sender: TObject);
var
temp:toutput;
i,j:integer;
begin
dec(count);
if count<1 then
begin
showmessage('입력된자료가 없습니다.');
edit1.setfocus;
exit;
end;
for i:=1 to count-1 do
for j:=i+1 to count do
if out_data[i].total_value>out_data[j].total_value then
begin
temp:=out_data[i];
out_data[i]:=out_data[j];
out_data[j]:=temp;
end;
frminput.hide;
frmoutput.show;
end;
procedure Tfrminput.FormCreate(Sender: TObject);
begin
count:=1;//폼이 열렸을 때 count값 1로 초기화
end;
end.
[Hint] Unit1.pas(74): Variable 'i' is declared but never used in 'Tfrminput.Button1Click'
[Hint] Unit1.pas(74): Variable 'discount' is declared but never used in 'Tfrminput.Button1Click'
[Hint] Unit1.pas(74): Variable 'ou1' is declared but never used in 'Tfrminput.Button1Click'
[Hint] Unit1.pas(74): Variable 'out2' is declared but never used in 'Tfrminput.Button1Click'
[Hint] Unit1.pas(74): Variable 'call_value' is declared but never used in 'Tfrminput.Button1Click'
[Hint] Unit1.pas(75): Variable 'disrate' is declared but never used in 'Tfrminput.Button1Click'
[Error] Unit1.pas(94): Declaration expected but 'IF' found
[Error] Unit1.pas(99): Undeclared identifier: 'edit1'
[Error] Unit1.pas(99): Missing operator or semicolon
[Error] Unit1.pas(100): Missing operator or semicolon
[Error] Unit1.pas(102): '.' expected but ';' found
[Error] Unit1.pas(106): Identifier redeclared: 'Finalization'
[Error] Unit1.pas(108): ')' expected but identifier 'text' found
[Error] Unit1.pas(110): Undeclared identifier: 'dep_name'
[Error] Unit1.pas(111): Undeclared identifier: 'call_num'
[Error] Unit1.pas(113): ')' expected but identifier 'text' found
[Error] Unit1.pas(118): ')' expected but identifier 'text' found
[Error] Unit1.pas(123): ')' expected but identifier 'text' found
[Error] Unit1.pas(128): ')' expected but identifier 'text' found
[Error] Unit1.pas(136): Missing operator or semicolon
[Error] Unit1.pas(137): Missing operator or semicolon
[Error] Unit1.pas(142): Undeclared identifier: 'edit2'
[Error] Unit1.pas(144): Undeclared identifier: 'in_value'
[Error] Unit1.pas(144): Missing operator or semicolon
[Error] Unit1.pas(145): Statement expected, but expression of type 'Text' found
[Error] Unit1.pas(149): Missing operator or semicolon
[Error] Unit1.pas(150): Missing operator or semicolon
[Error] Unit1.pas(157): Undeclared identifier: 'edit3'
[Error] Unit1.pas(159): Undeclared identifier: 'out1'
[Error] Unit1.pas(159): Missing operator or semicolon
[Error] Unit1.pas(160): Statement expected, but expression of type 'Text' found
[Error] Unit1.pas(164): Missing operator or semicolon
[Error] Unit1.pas(165): Missing operator or semicolon
[Error] Unit1.pas(169): Undeclared identifier: 'edit4'
[Error] Unit1.pas(171): Undeclared identifier: 'out2'
[Error] Unit1.pas(171): Missing operator or semicolon
[Error] Unit1.pas(172): Statement expected, but expression of type 'Text' found
[Error] Unit1.pas(176): Missing operator or semicolon
[Error] Unit1.pas(177): Missing operator or semicolon
[Error] Unit1.pas(181): Undeclared identifier: 'out_value'
[Error] Unit1.pas(187): Undeclared identifier: 'edit5'
[Error] Unit1.pas(189): Undeclared identifier: 'disrate'
[Error] Unit1.pas(191): ')' expected but identifier 'text' found
[Error] Unit1.pas(195): Undeclared identifier: 'eidt5'
[Error] Unit1.pas(201): Undeclared identifier: 'call_value'
[Error] Unit1.pas(202): Undeclared identifier: 'tax'
[Error] Unit1.pas(203): Undeclared identifier: 'discount'
[Error] Unit1.pas(204): Undeclared identifier: 'total_value'
[Error] Unit1.pas(208): Undeclared identifier: 'etc'
[Error] Unit1.pas(219): Missing operator or semicolon
[Error] Unit1.pas(220): Missing operator or semicolon
[Error] Unit1.pas(220): Missing operator or semicolon
[Error] Unit1.pas(221): Missing operator or semicolon
[Error] Unit1.pas(221): Missing operator or semicolon
[Error] Unit1.pas(222): Missing operator or semicolon
[Error] Unit1.pas(222): Missing operator or semicolon
전 왕초보입니다.(델파이 시작 4일째..)
분명히 다 정의를 해주었는데 이런 에러가 납니다...
도와주세요.... 부탁드려요...
제가 델파이로 정보처리기사 시험을 보려는데 너무 어렵습니다...
도와주세요..도와주세요...
T.T;;
거의 모든 에러가, 스트링변수를 숫자형변수로 변환해주지 않아서 생긴것이고
나머지는 오타입니다.
if (edit1.text>3)
여기서 edit1.text는 string형이고, 3은 숫자입니다.
이것을 비교하려면, StrToInt를 사용해서 형변환을 해줘야합니다.
stttoint(edit1.text)>3
----------------------------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TfrmInput = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmInput: TfrmInput;
count:integer;
implementation
{$R *.DFM}
type Tinput=record
dep_code:string;//부서코드
in_num :string; //시내통화량
out1_num : string;//시외 1대역 통화량
out2_num: string; //시외 2대역 통화량
method:string//결재코드
end;
{출력 자료 형식 정의}
type Toutput=record
dep_name:string;//부서명
call_num:string;//전화번호
in_value:integer;//시내통화금액
out_value:integer;//시외통화금액
tax:integer;//세금
total_value:integer;//통화총액
etc:string //비고
end;
var
in_data:array[1..7] of tinput ; //입력자료배열선언
out_data:array[1..7] of toutput; //출력자료 배열선언
procedure TfrmInput.Button1Click(Sender: TObject);
var
i,discount,out1,out2,call_value:integer;//루프용변수
disrate:real;
begin
{최대 입력건수는 7건이하로 간주한다.}
if count>7 then begin
showmessage('최대입력건수를 초과하였습니다.');
exit;
end;
if count >= 2 then
for i:=1 to count-1 do
if uppercase(in_data[i].dep_code) = uppercase(edit1.text) then
begin
showmessage('부서코드가 중복되었습니다.');
edit1.text:='';
edit1.setfocus;
exit;
end;
with Out_data[count] do
begin
{부서명과 전화번호를 구한다.}
if uppercase(edit1.text)='A' then
begin
dep_name:='총무부';
call_num:='940-8857';
end
else if uppercase(edit1.text)='B' then
begin
dep_name:='인사부';
call_num:='940-6589';
end
else if uppercase(edit1.text)='C' then
begin
dep_name:='영업1부';
call_num:='940-7740';
end
else if uppercase(edit1.text) ='D' then
begin
dep_name:='영업2부';
call_num:='940-5212';
end
else if uppercase(edit1.text) ='E' then
begin
dep_name:='영업3부';
call_num:='940-6320';
end
else
begin
showmessage('부서코드 입력 오류입니다.!');
edit1.text:='';
edit1.setfocus;
exit;
end;
{시내통화량을 입력한다. 단,3자리 이하의 정수로 입력}
if (edit2.text<>'') and (strtoint(edit2.text)>0) and (strtoint(edit2.text)<=999) then
begin
in_value := 50*strtoint(edit2.text);
end
else
begin
showmessage('시내 통화량 입력오류!!');
edit2.text:='';
edit2.setfocus;
exit;
end;
{시외1대역 통화량과 시외 2대역 통화량을 3자리 이하의 정수로 입력}
if (edit3.text<>'') and (strtoint(edit3.text)>0) and (strtoint(edit3.text)<=999) then
begin
out1 := strtoint(edit3.text);
end
else
begin
showmessage('시외 1대역 통화량 입력오류!!');
edit3.text:='';
edit3.setfocus;
exit;
end;
if (edit4.text<>'') and (strtoint(edit4.text)>0) and (strtoint(edit4.text)<=999) then
begin
out2:= strtoint(edit4.text);
end
else
begin
showmessage('시외 1대역 통화량 입력오류!!');
edit4.text:='';
edit4.setfocus;
exit;
end;
out_value:= (out1*80)+(out2*120);
{결재코드표에 따른 할인률입력}
if uppercase(edit5.text)='PA' then
begin
disrate := 0;
end
else if uppercase(edit5.text)='PB' then
begin
disrate := 0.02;
end
else if uppercase(edit5.text)='PC' then
begin
disrate := 0.05;
end;
call_value:=in_value+out_value+3000;
tax:=round(call_value*0.1);
discount:=round(call_value+tax*disrate);
total_value:=(call_value+tax+3000)-discount;
if (total_value<=30000) then
begin
etc:='절약';
end
else
begin
etc:='';
exit;
end;
{입력배열에 자료 저장}
with in_data[count] do
begin
dep_code :=edit1.text;
in_num :=edit2.text;
out1_num :=edit3.text;
out2_num :=edit4.text;
method :=edit5.text;
end;
{입력을 초기화}
edit1.text:='';
edit2.text:='';
edit3.text:='';
edit4.text:='';
edit5.text:='';
edit1.setfocus;
inc(count);
end;
end;
procedure TfrmInput.Button2Click(Sender: TObject);
var
temp:toutput;
i,j:integer;
begin
dec(count);
if count<1 then
begin
showmessage('입력된자료가 없습니다.');
edit1.setfocus;
exit;
end;
for i:=1 to count-1 do
for j:=i+1 to count do
if out_data[i].total_value>out_data[j].total_value then
begin
temp:=out_data[i];
out_data[i]:=out_data[j];
out_data[j]:=temp;
end;
frminput.hide;
frmoutput.show;
end;
end.