Link to home
Start Free TrialLog in
Avatar of Denis Orozco
Denis OrozcoFlag for United States of America

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Denis Orozco

ASKER

This will not work because the amount I have provided were sample ones and they vary depending on the category they are in.
what kind of "Categories" need to be defined here? How you define these categories?