By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,168 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

Easy way to pass a sender to a subroutine? Maybe I didn't word that right...

P: n/a
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!
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.