Find if a number is part of a range

Hi there,
I have a little bit of an issue. I need to find out if a number is part of a giving range.
I have the following code:
Dim dt as new datatable
Dim dtrow as datarow
Dt = loaddata()

For each dtrow in dt.rows then
Dim str as string = dtrow.items("unit").tostring()
Dim range as string = dtrow.items("range").tostring()
'Some how in here I need create a function or sub that will tell me if the str is in my range or not
Next

Open in new window

The datatable has units like this
5.000
6.00000
1.0000
23000.00
And ranges are like this:
1
2 to 5
6 to 20
21 to 50
50 >
For the bigger numbers those are dollars amounts and behave the same way.
How can I do this?
Thanks
COHFLAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
you can try create a function accordingly for comparison.

Function findRange(v As Double) As String
       Select Case v
         Case Is > 50
                  Return "50 >"
         Case Is >= 21
                  Return "21 to 50"
         Case Is >=6
                  Return "6 to 20"
         Case Is >=2
                  Return "2 to 5"
         Case Is =1
                  Return "1"
         Case Else
                  Return "< 1"
       End Select
End Function

Open in new window


then:

myRange = findRange(Convert.ToDouble(dtrow.items("range").tostring()))

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
COHFLAuthor Commented:
This will not work because the amount I have provided were sample ones and they vary depending on the category they are in.
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
what kind of "Categories" need to be defined here? How you define these categories?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.