View Full Version : Solved: Spin buttons
maninjapan
09-10-2008, 12:12 AM
New to VBA here. Making my first attempt at a Userform. Am trying to use the Spin button function to increase/decrease by 1.
I have most of it but just need to know what the XXXX bit should be.
Private Sub SpinButtonLots_SpinDown()
' Reduces Lot size by 1
TextBoxSpin.Text = XXXXX(TextBoxSpin.Text) - 1
End Sub
thanks in Advance
Bob Phillips
09-10-2008, 12:53 AM
Private Sub SpinButtonLots_SpinDown()
' Reduces Lot size by 1
TextBoxSpin.Text = Val(TextBoxSpin.Text) - 1
End Sub
maninjapan
09-10-2008, 02:06 AM
Simple as that..... Thanks.
I have now tried to use the spin button to adjust the date.
I tried the following (as explained in Microsoft Help and Support)
Private Sub SpinButtonDate_SpinDown()
' Reduces Date by 1 day
TextBoxDate.Text = DateValue(TextBoxDate.Text) - 1
End Sub
however I recieved an Error 13 in regards to the 3rd line.
There was also a module with the following
Sub ShowForm()
TextBox1.Text = Date
UserForm1.Show
End Sub
Not sure how to fix this error...
Bob Phillips
09-10-2008, 02:15 AM
Private Sub SpinButtonDate_SpinDown()
With Me.TextBoxDate
' Reduces Date by 1 day
.Text = Format(DateValue(.Text) - 1, "dd mmm yyyy")
End With
End Sub
and
Sub ShowForm()
UserForm1.TextBoxDate.Text = Format(Date, "dd mmm yyyy")
UserForm1.Show
End Sub
maninjapan
09-10-2008, 02:32 AM
thanks XLD, Tried the following but still came back with the same error(13)
on the 4th line.....
Private Sub SpinButtonDate_SpinDown()
With Me.TextBoxDate
' Reduces Date by 1 day
.Text = Format(DateValue(.Text) - 1, "dd mmm yyyy")
End With
End Sub
Bob Phillips
09-10-2008, 02:50 AM
Did you pre-load it as per the other code?
maninjapan
09-10-2008, 03:45 AM
sorry, what do you mean by pre-load it?
Bob Phillips
09-10-2008, 03:55 AM
Sub ShowForm()
UserForm1.TextBoxDate.Text = Format(Date, "dd mmm yyyy")
UserForm1.Show
End Sub
maninjapan
09-10-2008, 04:29 AM
Ok I get what you mean now. It works fine now. I was trying to just run the Userform itself.
Another Problem solved.
Thanks a lot
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.