SpinButton Rounding Up
I've skipped the min/max validation, but this approach (or similar) may work
for you:
Private dblMyValue As Double
Private Sub SpinButton1_SpinUp()
dblMyValue = dblMyValue + SpinButton1.SmallChange
TextBox1.Text = dblMyValue
End Sub
Private Sub SpinButton1_SpinDown()
dblMyValue = dblMyValue - SpinButton1.SmallChange
TextBox1.Text = dblMyValue
End Sub
Private Sub TextBox1_Change()
dblMyValue = Val(TextBox1.Text)
If dblMyValue = SpinButton1.Min And _
dblMyValue <= SpinButton1.Max Then _
SpinButton1.Value = dblMyValue
End Sub
"Randal W. Hozeski" wrote in message
news:p3vFb.14921$VB2.33439@attbi_s51...
I use the following code in a SpinButton. If I manually edit the TextBox1
to 150.25 it is fine but when I use150.6, it rounds the result up and does
not allow the two decial point entry in fact any number over 150.5 turns
to 151. How can I keep the number entered as is without rounding it
up? Not sure which property needs adjusting,
Private Sub SpinButton1_Change()
TextBox1.Text = SpinButton1.Value
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
-Randy-
|