ExcelBanter

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

bruce forster

spin button
 
I am using the following code from Power Programming but would like to have the spin button increase the textbox by 0.25 increments. Any suggestion
__________________________________________________

Option Explici

Private Sub UserForm_Initialize(
With SpinButton
' Specify upper and lower limit
.Min =
.Max =
' Initialize TextBo
TextBox1.Text = 0.2
TextBox1.Text = Format(TextBox1.Text, "#.##0"
End Wit
End Su
Private Sub TextBox1_Change(
Dim NewVal As Intege
NewVal = Val(TextBox1.Text
If NewVal = SpinButton1.Min And
NewVal <= SpinButton1.Max Then
SpinButton1.Value = NewVa
End Su

Private Sub TextBox1_Enter(
' Selects all text when user enters TextBo
TextBox1.SelStart =
End Su

Private Sub SpinButton1_Change(
TextBox1.Text = SpinButton1.Valu
TextBox1.Text = Format(TextBox1.Text, "#.##0"
End Su
__________________________________________________ _________

Thanks.

Bob Phillips[_6_]

spin button
 
Bruce,

Here is one way

Private Sub UserForm_Initialize()
With SpinButton1
' Specify upper and lower limits
.Min = 0
.Max = 24
' Initialize TextBox
TextBox1.Text = 0.25
TextBox1.Text = Format(TextBox1.Text, "#.##0")
.Value = 1
End With
End Sub

Private Sub TextBox1_Enter()
' Selects all text when user enters TextBox
TextBox1.SelStart = 1
End Sub

Private Sub SpinButton1_Change()
With SpinButton1
If .Value = .Min And _
.Value <= .Max Then
TextBox1.Text = .Value / 4
End If
End With
TextBox1.Text = Format(TextBox1.Text, "#.##0")
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"bruce forster" wrote in message
...
I am using the following code from Power Programming but would like to

have the spin button increase the textbox by 0.25 increments. Any
suggestions
__________________________________________________ _

Option Explicit

Private Sub UserForm_Initialize()
With SpinButton1
' Specify upper and lower limits
.Min = 0
.Max = 6
' Initialize TextBox
TextBox1.Text = 0.25
TextBox1.Text = Format(TextBox1.Text, "#.##0")
End With
End Sub
Private Sub TextBox1_Change()
Dim NewVal As Integer
NewVal = Val(TextBox1.Text)
If NewVal = SpinButton1.Min And _
NewVal <= SpinButton1.Max Then _
SpinButton1.Value = NewVal
End Sub

Private Sub TextBox1_Enter()
' Selects all text when user enters TextBox
TextBox1.SelStart = 1
End Sub

Private Sub SpinButton1_Change()
TextBox1.Text = SpinButton1.Value
TextBox1.Text = Format(TextBox1.Text, "#.##0")
End Sub
__________________________________________________ __________

Thanks.





All times are GMT +1. The time now is 01:42 AM.

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