Assuming you have your global variable called prevvalue already setup in a module, you can use this code to do what you're looking for:
Private Sub NumberSpin_SpinDown()
Me.NumberBox.Text = Me.NumberBox.Value - 1
prevvalue = Me.NumberBox.Value
End Sub
Private Sub NumberSpin_SpinUp()
Me.NumberBox.Text = Me.NumberBox.Value + 1
prevvalue = Me.NumberBox.Value
End Sub
Private Sub NumberBox_Change()
If Not IsNumeric(Me.NumberBox.Value) Then
MsgBox "Numeric values only.", vbcritical + vbokonly, "Invalid input"
Me.NumberBox.Value = prevvalue
GoTo skipmark
End If
If Not (Me.NumberBox.Value - (Me.NumberBox.Value \ 1)) = 0 Then
MsgBox "Invalid value, use integers only.", vbcritical + vbokonly, "Invalid input"
Me.NumberBox.Value = prevvalue
Else
prevvalue = Me.NumberBox.Value
End If
skipmark:
End Sub
Private Sub UserForm_Initialize()
prevvalue = 0
Me.NumberBox.Text = "0"
End Sub
Bookmarks