| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 640 人关注过本帖
标题:枚举在CASE中的使用问题
只看楼主 加入收藏
liuqiang_sy
Rank: 1
等 级:新手上路
帖 子:57
专家分:0
注 册:2007-3-13
收藏
 问题点数:0 回复次数:1 
枚举在CASE中的使用问题

unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

type
Tcolor=(Yellow,Orange,Green,Black,Red,Silver,White); //这里我定了一个枚举类型.

{$R *.dfm}

var
m1:integer;
s1:Tcolor; //定义一个枚举类型的变量

procedure TForm1.Button1Click(Sender: TObject);
begin
m1:=strtoint(inputbox('月份转季节','请输入月份','1'));
case m1 of
2..4:
begin
showmessage('春天');
s1:=Green;
end;
5..7:
begin
showmessage('夏天');
s1:=Red;
end;
8..10:
begin
showmessage('秋天');
s1:=Silver;
end;
11..12,1:
begin
showmessage('冬天');
s1:=White;
end;
else
begin
showmessage('你不是地球人吗?');
s1:=Yellow;
end;
end
case s1 of
Green:
Label1.Caption:='春天';
Red:
Label1.Caption:='夏天';
Silver:
Label1.Caption:='秋天';
White:
Label1.Caption:='冬天';
end
label1.Color:=s1;
end;

end.

搜索更多相关主题的帖子: CASE 枚举 
2007-04-04 21:27
anthony634
Rank: 6Rank: 6
来 自:西南交大
等 级:贵宾
威 望:24
帖 子:653
专家分:10
注 册:2006-6-8
收藏
得分:0 

你有不少是拼写的问题啊,最后面哪个,我改了下可以运行了。

unit Unit1;

interface

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

type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

type
Tcolor=(Yellow,Orange,Green,Black,Red,Silver,White); //这里我定了一个枚举类型.

{$R *.dfm}

var
m1:integer;
s1:Tcolor; //定义一个枚举类型的变量

procedure TForm1.Button1Click(Sender: TObject);
begin
m1:=strtoint(inputbox('月份转季节','请输入月份','1'));
case m1 of
2..4:
begin
showmessage('春天');
s1:=Green;
Label1.Color:=clGreen;
end;
5..7:
begin
showmessage('夏天');
s1:=Red;
Label1.Color:=clred;
end;
8..10:
begin
showmessage('秋天');
s1:=Silver;
Label1.Color:=clSilver;
end;
11..12,1:
begin
showmessage('冬天');
s1:=White;
Label1.Color:=clWhite;
end;
else
begin
showmessage('嘿嘿,你是地球人吗?');
s1:=Yellow;
end;
end;
case s1 of
Green:
Label1.Caption:='春天';
Red:
Label1.Caption:='夏天';
Silver:
Label1.Caption:='秋天';
White:
Label1.Caption:='冬天';
else
label1.Color:=clBlack;
end;
end;
end.

[此贴子已经被作者于2007-4-4 21:44:29编辑过]

2007-04-04 21:43
快速回复:枚举在CASE中的使用问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024886 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved