Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Spin button questions
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? 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? Thanks for any and all help! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Spin button questions
Instead of keeping them syncronized, why not just have the textbox keep track of
the value and the spinner either increase or decrease that value in the textbox? Option Explicit Private Sub SpinButton1_SpinDown() With Me.TextBox1 .Value = Val(.Value) - 1 End With End Sub Private Sub SpinButton1_SpinUp() With Me.TextBox1 .Value = Val(.Value) + 1 End With End Sub Then if you need the current value, just look at val(me.textbox1.value) Norm wrote: 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? 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? Thanks for any and all help! -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Spin button questions
Thank You!!! That's a better solution.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
spin button value | Excel Discussion (Misc queries) | |||
spin button | Excel Programming | |||
Spin Button... | Excel Programming | |||
Excel spin button | Excel Programming | |||
Spin Button | Excel Programming |