Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Spin button questions

Thank You!!! That's a better solution.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
spin button value tina Excel Discussion (Misc queries) 2 March 17th 05 02:11 PM
spin button bruce forster Excel Programming 1 May 7th 04 12:21 AM
Spin Button... scottnshelly[_25_] Excel Programming 4 April 30th 04 07:49 AM
Excel spin button NIUBOB Excel Programming 0 January 15th 04 02:41 AM
Spin Button Andrew[_14_] Excel Programming 1 July 18th 03 01:51 AM


All times are GMT +1. The time now is 02:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"