View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Thomas Bartkus[_2_] Thomas Bartkus[_2_] is offline
external usenet poster
 
Posts: 4
Default Spin button questions

"Norm" wrote in message
...
I am making a simple user form for an Excel macro to use
instead of asking a bunch of questions to the user. (This
is from Office XP and Excel 2002.) The form has a text
box with a spin button beside it. Here's a
couple "beginner's" questions about it:

1) Since I need to keep the two controls syncronized, I
thought I would use the 'Change' event on each control to
update the other one. But wouldn't that lead to an
infinite loop? Example: when the text box changes, it
would trigger the 'Change' event to update the spin
button. But the spin button's 'Change' event would try to
update the text box. Would it ever end?


The question never occurs in the most typical situation where you simply
update a textbox from the SpinButton. You would leave the TextBox change
event empty and you would also disable manual entry to the TextBox by
setting the [Locked] property to true. You control the TextBox from the
SpinButton.

Did you mean you want to go *both* ways?
Updating the SpinBox *also* when the user types a number into the
TextBox?

It still doesn't go into an infinite loop. The number reflected back to the
TextBox from the SpinButton alteration will be the *same* number you already
typed in. Since the number is the same, it won't trigger a new change event
and the back and forth ends right there.

2) I wrote some simple code to try to update the spin
button from the text box and I run into an error that says
the property can't be updated. I am trying to set
the 'Value' property on the spin button. Can't that be
updated?


Of course it can!
I'm guessing your 'Value' falls outside the .Max and .Min properties of the
SpinButton. The 'Value' will be refused if it falls ouside this range.
Of course, you also need Locked = False and Enabled = True.

Thomas Bartkus