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

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
``````
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
Who is Participating?
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.

Commented:
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
``````

then:

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

Experts Exchange Solution brought to you by

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

Author Commented:
This will not work because the amount I have provided were sample ones and they vary depending on the category they are in.
0
Commented:
what kind of "Categories" need to be defined here? How you define these categories?
0
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.

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.