I am not very good at this but I'm trying to make a Time Picker using VBA userform.
I have 2 spin buttons, 'spinbutton1' to control hours and 'spinbutton2' for minutes, and textbox named 'tbtime'
I am having trouble because I need it to show as 24hr time, I also need it to not change date when I approach midnight
here is what I have so far that does not work that great
Thank you all!
I have 2 spin buttons, 'spinbutton1' to control hours and 'spinbutton2' for minutes, and textbox named 'tbtime'
I am having trouble because I need it to show as 24hr time, I also need it to not change date when I approach midnight
here is what I have so far that does not work that great
Code:
Private Sub SpinButton1_SpinDown()
mytime = CDate(Me.tbtime)
Me.tbtime = DateAdd("h", -1, mytime)
If Me.tbtime = CDate("00:00") Then
Me.tbtime = CDate("23:00")
End If
End Sub
Private Sub SpinButton1_Spinup()
mytime = CDate(Me.tbtime)
Me.tbtime = DateAdd("h", 1, mytime)
If Me.tbtime = CDate("23:00") Then
Me.tbtime = CDate("00:00")
End If
End Sub
Private Sub SpinButton2_SpinDown()
mytime = CDate(Me.tbtime)
Me.tbtime = DateAdd("n", -1, mytime)
If Me.tbtime = CDate("00:00") Then
Me.tbtime = CDate("00:59")
End If
End Sub
Private Sub SpinButton2_Spinup()
mytime = CDate(Me.tbtime)
Me.tbtime = DateAdd("n", 1, mytime)
If Me.tbtime = CDate("23:59") Then
Me.tbtime = CDate("00:00")
End If
End Sub
Thank you all!