If var [not] between LowerBound and UpperBound

根据数值或字母顺序检查变量的内容是否在两个值之间(包含边界).

if Var between LowerBound and UpperBound
if Var not between LowerBound and UpperBound

参数

Var

需要被检查的变量名称.

LowerBound

指定范围的下限, Var 必须大于或等于此字符串, 数字或变量引用.

UpperBound

指定范围的上限, Var 必须小于或等于此字符串, 数字或变量引用.

备注

如果这三个参数都为纯数值, 那么它们将被作为数字而不是字符串进行比较. 其他情况下, 它们将被作为字符串按字母顺序进行比较(即字母次序将决定 Var 是否在指定范围内). 此时, 可以使用 StringCaseSense On 来设置在比较时区分大小写.

警告: 运算符 "between", "is", "in" 和 "contains" 不支持用于表达式中.

相关

IfEqual/Greater/Less, if var in/contains MatchList, if var is type, IfInString, StringCaseSense, EnvAdd, 区块, Else

示例

#1

if var between 1 and 5
    MsgBox, %var% is in the range 1 to 5, inclusive.

if var not between 0.0 and 1.0
    MsgBox %var% is not in the range 0.0 to 1.0, inclusive.

if var between %VarLow% and %VarHigh%
    MsgBox %var% is between %VarLow% and %VarHigh%.

if var between blue and red
    MsgBox %var% is alphabetically between the words blue and red.

#2

LowerLimit := 1
UpperLimit := 10
InputBox, UserInput, Enter a number between %LowerLimit% and %UpperLimit%
if UserInput not between %LowerLimit% and %UpperLimit%
    MsgBox Your input is not within the valid range.