| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 480 人关注过本帖
标题:[求助][求助]如何实现变量是否在数字段的判断
只看楼主 加入收藏
mervynlove
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-2-7
收藏
 问题点数:0 回复次数:5 
[求助][求助]如何实现变量是否在数字段的判断

比如一个变量,我想判断它是不是在1到70之间,用代码该如何实现?

if VAR1=1..70 then

这样不行啊

搜索更多相关主题的帖子: 变量 数字 判断 
2007-02-07 16:49
sgliuxiu
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:291
专家分:0
注 册:2007-2-2
收藏
得分:0 

用in


小猫说:给我10元钱
2007-02-07 17:41
sgliuxiu
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:291
专家分:0
注 册:2007-2-2
收藏
得分:0 
我可能理解错了,如果是判断它是不是在什么之间,用if (var1>=0 and var1<=70) then...
如果是判断它在不在0--70里面,就用 in

[此贴子已经被作者于2007-2-7 17:50:06编辑过]


小猫说:给我10元钱
2007-02-07 17:49
mervynlove
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-2-7
收藏
得分:0 
谢谢,用in如何写?

if VAR1 in 1..70 then

这样好像不行哦
2007-02-07 18:30
sgliuxiu
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:291
专家分:0
注 册:2007-2-2
收藏
得分:0 
if var1 in  [ 1..70] then

小猫说:给我10元钱
2007-02-07 19:31
sgliuxiu
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:291
专家分:0
注 册:2007-2-2
收藏
得分:0 

你在delphi里面找关于集合的内容

我找到了点,你看看.

Because of the size limitations for base types, set types are usually defined with subranges. For example, the declarations

type
TSomeInts = 1..250;
TIntSet = set of TSomeInts;

create a set type called TIntSet whose values are collections of integers in the range from 1 to 250. You could accomplish the same thing with

type TIntSet = set of 1..250;

Given this declaration, you can create a sets like this:

var Set1, Set2: TIntSet;
...
Set1 := [1, 3, 5, 7, 9];
Set2 := [2, 4, 6, 8, 10]

You can also use the set of ... construction directly in variable declarations:

var MySet: set of 'a'..'z';
...
MySet := ['a','b','c'];

Other examples of set types include

set of Byte
set of (Club, Diamond, Heart, Spade)
set of Char;

The in operator tests set membership:

if 'a' in MySet then ... { do something } ;

Every set type can hold the empty set, denoted by [].


小猫说:给我10元钱
2007-02-07 19:38
快速回复:[求助][求助]如何实现变量是否在数字段的判断
数据加载中...
 
   



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

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