View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default 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