Quantcast
Channel: Micro Focus QTP (UFT) Forums - All Forums
Viewing all articles
Browse latest Browse all 1793

Using Range in Select Case Statement

$
0
0
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. 

Viewing all articles
Browse latest Browse all 1793

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>