Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sheepopo39

macrumors 6502
Original poster
Sep 18, 2008
251
0
I just recently made up a very simple application with a slider, a label, and a button. When the user hits the button it gets the value of what slider currently is at and sends it to the label. I have the slider start from 0 to 100, with 10 ticks. However the problem is, is that when I hit the buttons, the values are slightly off, i.e 11, instead of 10 and 88 instead of 90, it seems to go up in denominations of 11. Does anyone know how I can fix this?

Thanks,

John.

Edit: Also when I try to change the current value in IB, say I enter 10 it takes it to 11.1, also I have only stop on ticks set.
 

Sydde

macrumors 68030
Aug 17, 2009
2,552
7,050
IOKWARDI
If you want your tick marks to hit at every factor of 10 from 0 to 100, try using 11 ticks instead of 10.
 

sheepopo39

macrumors 6502
Original poster
Sep 18, 2008
251
0
Alright, it worked, thanks a lot, although, is there any way I could do it with ten? Though now I think of it, 11 makes a lot more sense.
 

Sydde

macrumors 68030
Aug 17, 2009
2,552
7,050
IOKWARDI
AFAIK, the only way to do it with ten ticks is to make 10 your minimum value. I have always found inclusive math to be a pain in the head (like trying to figure out substring ranges, back in the old days). Think of it this way: there are ten integer values from 1 to 10 - if you want to include 0 in that range, you end up with 11 values.

You might also want to look at continuous controls and/or bindings so that the value gets updated constantly instead of needing a button click to update.
 

sheepopo39

macrumors 6502
Original poster
Sep 18, 2008
251
0
Thanks a lot, it's a lot more clearer now. Also, thanks for the recommendation, I was gonna do that later too, but I just wanted to get the whole stuff down first.

Thanks,

John.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.