• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

Select in range in VBScript

How do I select within a range in VBScript?

Dim intInteger

intInteger = 5

Select Case intInteger
     Case 1 to 5
            'do something
     Case 6 to 10
            'do something else
End select


Also tried with Cint(intInteger) and tried many strategies like
1 or 2 or 3 or 4 or 5


>0 & <6


Did we just get shafted on this one, or is something I'm missing?


1 Solution
Hi ic,

U can select using

Dim intInteger

intInteger = 5

If intInteger >= 1 And intInteger <= 5 Then
            MsgBox "do something"
ElseIf intInteger >= 6 And intInteger <= 10 Then
            MsgBox "do something else"
End If


Select Case intInteger
     Case 1,2,3,4,5
            MsgBox "do something"
     Case 6,7,8,9,10
            MsgBox "do something else"
End select

Hope that helps,

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now