Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using Range in Select Case Statement
#1
Not Solved
Hi all, 


So I am very new to qtp and I was wondering if anyone could provide some input. So I am a little bit confused about the select case statement. Here is my statement below.

 Age = inputbox("enter age")

Select Case Age
    Case > 5
    msgbox "young"
    Case 6 to 15
    msgbox "still young"
    Case 16 , 21
    msgbox "still young"
    Case 22 , 30
    msgbox "get your own spot"
    Case 31 , 100
    msgbox "settled"
End Select

My question is how do I use range, in this case, I have tried a lot of different ways but nothing seems to work.
but I did manage to get this to work, but there has to be a simpler way. 

Select Case Age

    Case 1,2,3,4,5
    msgbox "too oung"
    Case 6,7,8,9,10,11,12,13,14,15
    msgbox "still young"
    Case 16,17,18,19,20, 21
    msgbox "growing up"
End Select

I want to know if there is an easier way to write this, instead of writing all of the integers. I want the first case value to be 1 through 5 if that's possible and so on and so forth. Any help or tips would be greatly appreciated. Thanks in advance. 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Select case is not being executed in a Function Anupama 1 1,646 05-25-2018, 11:15 AM
Last Post: Anupama
  Using Select Case Statement Studymode 0 11,780 12-13-2017, 05:55 AM
Last Post: Studymode
  Case changes while reading values from inbuilt datatables krishnakittu03 3 3,017 04-28-2015, 11:34 AM
Last Post: kbhargava505
  Webelement innertext is not case sensitive san4hex 7 6,288 05-13-2013, 02:59 PM
Last Post: basanth27
  Case Statement adelitza 2 4,670 09-07-2012, 12:20 PM
Last Post: Ankesh

Forum Jump:


Users browsing this thread: 2 Guest(s)