P
Patrick
Hello - I'm working on a project to have 6 labels, each with a value of 0 -
9. Each label has a 2 buttons on the side, one labeled up, one labeled down.
I want the up button to increment til it hits 9, the down button to
decriment til it hits 0. That part I can do, but it's very ugly.
What I want to do is have a routine that handles the Up Buttons, a routine
that handles the Down Buttons, both of them then call a subroutine called
ChangeRange that does the work. The way I have it is by doing a clumsy if
then else for every set of buttons, as below:
private handles down buttons
intModifier = -1
call ChangeRange
private handles up buttons
intModfier = 1
call ChangeRange
Sub ChangeRange
if sender is up1button or sender is down1button then....
intNumber1 = intNumber1 + (intModifier * 1)
if sender is up2button or sender is down2button then....
intNumber2 = intNumber2 + (intModifier * 1)
if sender up2button then...
End if
me.number1label.text = intNumber1
me.number2label.text = intNumber2
me.number3... etc
The problem is I know there has to be a way to have one calc that applies to
whatever button was sent and it's corresponding variable (up1button and
down1button both apply to intNumber1), but my knowledge is very limited
right now. Any help would be appreciated!
9. Each label has a 2 buttons on the side, one labeled up, one labeled down.
I want the up button to increment til it hits 9, the down button to
decriment til it hits 0. That part I can do, but it's very ugly.
What I want to do is have a routine that handles the Up Buttons, a routine
that handles the Down Buttons, both of them then call a subroutine called
ChangeRange that does the work. The way I have it is by doing a clumsy if
then else for every set of buttons, as below:
private handles down buttons
intModifier = -1
call ChangeRange
private handles up buttons
intModfier = 1
call ChangeRange
Sub ChangeRange
if sender is up1button or sender is down1button then....
intNumber1 = intNumber1 + (intModifier * 1)
if sender is up2button or sender is down2button then....
intNumber2 = intNumber2 + (intModifier * 1)
if sender up2button then...
End if
me.number1label.text = intNumber1
me.number2label.text = intNumber2
me.number3... etc
The problem is I know there has to be a way to have one calc that applies to
whatever button was sent and it's corresponding variable (up1button and
down1button both apply to intNumber1), but my knowledge is very limited
right now. Any help would be appreciated!