# Case Between Numbers

## Recommended Posts

Hi Everyone

I have this:

```Case \$res = "05333520"
\$ans = "5"
Case \$res = "05333620"
\$ans = "5"
Case \$res = "05333610"
\$ans = "5"
Case \$res = "05333610"
\$ans = "5"
Case \$res = "05333640"
\$ans = "5"```

How can you do a case between numbers so I dont have to make so many possibilities

ie.

```Case \$res = Between  05200000 & 05400000
\$ans = "5"```

Thanks for help

Edited by eskermeko

##### Share on other sites

Use Switch...Case...EndSwitch

there is "Case <value> [To <value>]"

```Switch \$res
Case 05200000 To 05400000
; statement1
; ...```

##### Share on other sites

Thanks thats perfect.

Edited by eskermeko

##### Share on other sites

Thanks thats perfect.

Zedna gave you the best answer, I just wanted to point out that you can use boolean logic to get that comparison in other situations too:

`If \$res >= 05200000 And \$res <= 05400000 Then MsgBox(0, "", "It's between!")`

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account