ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   spin button code (https://www.excelbanter.com/excel-programming/342733-spin-button-code.html)

jhahes[_41_]

spin button code
 

How do I get the spin button to control the text box

I want TextNumberOfGames(TextBox) to change when the
SpinNumberOfGames(SpinButton) is clicked up or down.

This is all in a form. I have already set the min, max, and change.

I would also like, if possible for the default to be 1, when the form
opens.


Thanks

Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=475931


JakeyC

spin button code
 
One way of doing it would be the following code (you'll have to insert
your limits)...

Option Explicit
Public i As Integer

Private Sub SpinNumberOfGames_SpinDown()
i = i - 1
TextNumberOfGames.Value = i

End Sub

Private Sub SpinNumberOfGames_SpinUp()
i = i + 1
TextNumberOfGames.Value = i

End Sub

Private Sub UserForm_Activate()
i = 1
TextNumberOfGames.Value = i

End Sub


Tom Ogilvy

spin button code
 
In the change event of the spin button, update the textbox with the value of
the spin button

In the initialize event of the userform, change the value of the spinbutton
to 1.

--
Regards,
Tom Ogilvy


"jhahes" wrote in
message ...

How do I get the spin button to control the text box

I want TextNumberOfGames(TextBox) to change when the
SpinNumberOfGames(SpinButton) is clicked up or down.

This is all in a form. I have already set the min, max, and change.

I would also like, if possible for the default to be 1, when the form
opens.


Thanks

Josh


--
jhahes
------------------------------------------------------------------------
jhahes's Profile:

http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=475931




JakeyC

spin button code
 
....and I never knew a SpinButton held its own value. Makes sense
really...



All times are GMT +1. The time now is 12:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com