spin button code

  • Thread starter Thread starter jhahes
  • Start date Start date
J

jhahes

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
 
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
 
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.
 
Back
Top