# How to deal with numbers not on a specified value? (between two?)

• (2 Pages)
• 1
• 2

## 22 Replies - 873 Views - Last Post: 10 July 2014 - 10:31 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=350109&amp;s=0587efeed7e368a1893854e4f9e55628&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 ZakaryHansen

Reputation: 0
• Posts: 137
• Joined: 28-February 14

# How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 07:54 AM

So, I'm trying to make a section of a program that will take a numerical value and will spit out a combobox.selecteditem.

The only problem is, if the value isn't on the exact points, it won't work. Example:
```If Value_A = 5 Then
ComboBox.SelectedItem = "Example 1"
ElseIf Value_A = 10 Then
ComboBox.SelectedItem = "Example 2"
ElseIf Value_A <= 15 Then
ComboBox.SelectedItem = "Example 3"
```
With that coding, if they're not on the exact value specified, the combobox won't select an item.

I tried using this coding to work around that, but some values aren't being picked up and I'm not sure why.
```If Value_A >= 0 And Value_A <= (5 + 10) / 2) Then
ComboBox.SelectedItem = "Example 1"
ElseIf Value_A > ((5 + 10) / 2) And Value_A <= ((10 + 15) / 2) Then
ComboBox.SelectedItem = "Example 2"
ElseIf Value_A > ((10 + 15) / 2) And Value_A <= 15 Then
ComboBox.SelectedItem = "Example 3"
```

This post has been edited by ZakaryHansen: 10 July 2014 - 08:45 AM

Is This A Good Question/Topic? 0

## Replies To: How to deal with numbers not on a specified value? (between two?)

### #2 DarenR

• D.I.C Lover

Reputation: 515
• Posts: 3,455
• Joined: 12-January 10

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 07:58 AM

i am a little lost at what you are asking-- can you elaborate

### #3 ZakaryHansen

Reputation: 0
• Posts: 137
• Joined: 28-February 14

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 08:10 AM

The form will have a NumericUpDown and a ComboBox.

The user will be able to enter values in the UpDown and depending on the value, the combobox's selected item will change.

I initially wanted it to be multiples of 5, but if the value isn't an exact multiple, like 4, the combobox wouldn't change.

So if the Value is between 0 and 5, it'll be "Example 1"
If the Value is between 6 and 13, it'll be "Example 2"
And so on.

### #4 modi123_1

• Suitor #2

Reputation: 10587
• Posts: 41,011
• Joined: 12-June 08

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 08:20 AM

Quote

So if the Value is between 0 and 5, it'll be "Example 1"

0, 1, 2, 3, 4, 5.. that's six digits, right?

Quote

If the Value is between 6 and 13, it'll be "Example 2"

6, 7, 8, 9, 10 ,11, 12, 13.. that's eight digits, right?

What is the pattern supposed to be?

How many "Example 1", "Example 2", etc are there? Presumably you can do the sequence algorithm by hand and apply it.

### #5 DarenR

• D.I.C Lover

Reputation: 515
• Posts: 3,455
• Joined: 12-January 10

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 08:21 AM

can you post an image so i can get an idea of these structures?-- i understand combobox but not the numericupdown

### #6 ZakaryHansen

Reputation: 0
• Posts: 137
• Joined: 28-February 14

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 08:27 AM

modi123_1, on 10 July 2014 - 08:20 AM, said:

What is the pattern supposed to be?

How many "Example 1", "Example 2", etc are there? Presumably you can do the sequence algorithm by hand and apply it.

So, wait. That first one should be 0-8.

Since 0 is not an option, there will be nothing before that five so it will have slightly more than others.
<=0, 1, 2, 3, 4, 5, 6, 7, <=8.

<8, 9, 10, 11, 12, <=13.
<13, 14, 15, 16, 17, <=18.
<18, 19, 20, 21, 22, <=23, etc.

There will be 100 possible combobox items that can be selected through this method.

This post has been edited by ZakaryHansen: 10 July 2014 - 08:28 AM

### #7 modi123_1

• Suitor #2

Reputation: 10587
• Posts: 41,011
• Joined: 12-June 08

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 08:33 AM

What you are explaining makes no sense. *WHY* is there no zero and how come that makes it 0-8? (because in your first post it appears zero to what ever is for 'example1')

### #8 DarenR

• D.I.C Lover

Reputation: 515
• Posts: 3,455
• Joined: 12-January 10

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 08:40 AM

modi123_1, on 10 July 2014 - 11:33 AM, said:

What you are explaining makes no sense. *WHY* is there no zero and how come that makes it 0-8? (because in your first post it appears zero to what ever is for 'example1')

i agree modi-- that is why i asked for an image of what he is trying to accomplish

### #9 ZakaryHansen

Reputation: 0
• Posts: 137
• Joined: 28-February 14

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 08:44 AM

I apologize for the confusion.

With my initial coding, it was only multiples of 5, starting at 5. {5, 10, 15, 20, etc.}
However, I want the user to be able to view the values around them as well.

So since 5 was the lowest value, they'd be able to see from 0 and then the midpoint of 5-10.
Then from there, it'd be range of the midpoints between the point before and the after that multiple.
For initial value of 15, it'd be the midpoints between 5-10 and 10-15
For initial value of 15, it'd be the midpoints between 10-25 and 15-20, etc.

That's why I tried doing the second coding in the first post.
```If Value_A >= 0 And Value_A <= (5+10) / 2 Then
'initial Value of 5
ElseIf Value_A > (0+10) / 2 And Value_A <= (10+15) / 2 Then
'Initial value of 10
```

And that first post had a mistake. That "(0+10) / 2" was supposed to be "(5+10) / 2"

### #10 modi123_1

• Suitor #2

Reputation: 10587
• Posts: 41,011
• Joined: 12-June 08

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 08:51 AM

Quote

With my initial coding, it was only multiples of 5, starting at 5. {5, 10, 15, 20, etc.}
However, I want the user to be able to view the values around them as well.

Then I ask - why? Why not have discrete steps change specific combo boxes? Why ranges?

Where the heck did the 8 come from/go to?

Quote

So since 5 was the lowest value, they'd be able to see from 0 and then the midpoint of 5-10.

This doesn't make sense. If 5 is the lowest value why are people "seeing" from 0?

Quote

For initial value of 15, it'd be the midpoints between 5-10 and 10-15
For initial value of 15, it'd be the midpoints between 10-25 and 15-20, etc.

That doesn't make sense either.. 15 is not a mid point in 5-10 or 10-15.

### #11 DarenR

• D.I.C Lover

Reputation: 515
• Posts: 3,455
• Joined: 12-January 10

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 08:57 AM

instead of having user input why not just make another combo box and tie it to the other one-- this way you know you will get the right info

### #12 ZakaryHansen

Reputation: 0
• Posts: 137
• Joined: 28-February 14

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 08:58 AM

modi123_1, on 10 July 2014 - 08:51 AM, said:

Then I ask - why? Why not have discrete steps change specific combo boxes? Why ranges?

Where the heck did the 8 come from/go to?
This doesn't make sense. If 5 is the lowest value why are people "seeing" from 0?

8 was the rounded midpoint of 5 and 10, which is 7.5 in reality.

The lowest Value IS 0. You'd then increment digits of 5, however, they can still type "1" or "2", etc.

Even if I made the increment 5, they can still just type six in. That's why I'd like it to read from the midpoints.

Quote

That doesn't make sense either.. 15 is not a mid point in 5-10 or 10-15.

Those "5-10 and 10-15" are saying I'm getting the midpoint between those two points.

Midpoint between 5 and ten. Midpoint between 10 and 15, hence the "MIDPOINTS BETWEEN".

Clearly, this site can't help with this. Ignore the question and carry on.

Thanks anyways.

This post has been edited by ZakaryHansen: 10 July 2014 - 09:39 AM

### #13 DarenR

• D.I.C Lover

Reputation: 515
• Posts: 3,455
• Joined: 12-January 10

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 09:05 AM

wow -- you come in here asking for help and very bad at explaining the problem-- people try to help you and you get pissed because no one can understand what you are asking--- I can see if one person doesnt understand what you are asking but when it is multiple people, perhaps the community isnt the problem.

### #14 modi123_1

• Suitor #2

Reputation: 10587
• Posts: 41,011
• Joined: 12-June 08

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 09:07 AM

Quote

Even if I made the increment 5, they can still just type six in. That's why I'd like it to read from the midpoints.

Again, I am unsure *WHY* you would bother with ranges as it is. Why not make a one to one translation from tbe increment box to the combo box?

Quote

8 was the rounded midpoint of 10 and 15, which is 7.5 in reality.

No.. the midpoint between 10 and 15 is 12.5. (unless you are using the term 'midpoint' in some non common language fashion).

Quote

The lowest Value IS 0. You'd then increment digits of 5, however, they can still type "1" or "2", etc.

Those "5-10 and 10-15" are saying I'm getting the midpoint between those two points.

Wow.. so that changes things. When you are throwing around ranges and then put in the "5-10" one would figure you are talking about the range between five and ten.. not that you are adding five and tend and dividing by two... or "10-15" (Lord knows I would have hated to interpret that as 10 minus 15!)

Quote

Clearly, this site can't help with this. Ignore the question and carry on.

Indeed - a shifting problem instructions and communication difficulties make group problem solving hard! Hopefully you are able to explain it better to other folk! Good luck!

### #15 ZakaryHansen

Reputation: 0
• Posts: 137
• Joined: 28-February 14

## Re: How to deal with numbers not on a specified value? (between two?)

Posted 10 July 2014 - 09:16 AM

I was being as clear as I was able to and there was still no understanding, so it's fine. I'll figure it out on my own.