使用Delphi制作字典的程序出了什么问题? ( 积分: 100 )

S

shijies

Unregistered / Unconfirmed
GUEST, unregistred user!
在窗口中放入两个label控件,一个用于说明,一个用于显示结果,在窗口中放入一个按钮,在按钮里加入以下程序:
var dataarray:array[1..4]of string;
i:integer;
begin
dataarray[1]:='powder';
dataarray[2]:='lubricant';
dataarray[3]:='metallurgy';
dataarray[4]:='steel';
for i:=1 to 4do
if trim(edit1.text)=dataarray then
case i of
1:label2.caption:='粉末';
2:label2.caption:='润滑剂';
3:label2.caption:='冶金';
4:label2.caption:='钢';
else
label2.caption:='不是粉末冶金术语';
 
在窗口中放入两个label控件,一个用于说明,一个用于显示结果,在窗口中放入一个按钮,在按钮里加入以下程序:
var dataarray:array[1..4]of string;
i:integer;
begin
dataarray[1]:='powder';
dataarray[2]:='lubricant';
dataarray[3]:='metallurgy';
dataarray[4]:='steel';
for i:=1 to 4do
if trim(edit1.text)=dataarray then
case i of
1:label2.caption:='粉末';
2:label2.caption:='润滑剂';
3:label2.caption:='冶金';
4:label2.caption:='钢';
else
label2.caption:='不是粉末冶金术语';
 
没有问题呀!
 

在窗口中放入两个label控件,一个用于说明,一个用于显示结果,一个edit控件用于输入,在窗口中放入一个按钮,在按钮里加入以下程序:
var dataarray:array[1..4]of string;
i:integer;
begin
dataarray[1]:='powder';
dataarray[2]:='lubricant';
dataarray[3]:='metallurgy';
dataarray[4]:='steel';
for i:=1 to 4do
if trim(edit1.text)=dataarray then
case i of
1:label2.caption:='粉末';
2:label2.caption:='润滑剂';
3:label2.caption:='冶金';
4:label2.caption:='钢';
else
label2.caption:='不是粉末冶金术语';
在输入上述代码后,出现提示如下信息:
[Error]Unit1.pas[50]:';'expected but '.' found
[Error]Unit1.pas[52]:Declaration expected but end of file found
[Fatal Error]Project1.dpr[5]:Could not compile used unit 'Unit1.pas'
 
case i of
1:label2.caption:='粉末';
2:label2.caption:='润滑剂';
3:label2.caption:='冶金';
4:label2.caption:='钢';
else
label2.caption:='不是粉末冶金术语';
后面加END
case i of
1:label2.caption:='粉末';
2:label2.caption:='润滑剂';
3:label2.caption:='冶金';
4:label2.caption:='钢';
else
label2.caption:='不是粉末冶金术语';
end;
 
case后面要加end
for语句用begin
...end括起来
 
看你的意思应该是这个要求吧:
for i := 1 to 4do
if trim(edit1.text) = dataarray then
case i of
1: label2.caption := '粉末';
2: label2.caption := '润滑剂';
3: label2.caption := '冶金';
4: label2.caption := '钢';
end
else
label2.caption := '不是粉末冶金术语';
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
665
import
I
I
回复
0
查看
723
import
I
顶部