Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UpDown Control question...

Status
Not open for further replies.

Sheffield

Programmer
Jun 1, 2001
180
US
Greetings,

I'm attempting to use an UpDown Control in conjunction with a TextBox that has the system time (10:05 AM, for example) captured as its text property. I would like to increment the time and perform some calculations based on the current system time, but can't seem to make it work.

Can anyone provide a similiar example of this?
Is this even possible?
Is there a better way?

Your help is much appreciated.
 
Hi sheffield,

Try this one.

Private Sub Form_Load()
TxtTime = Format(Now, "HH:MM:SS")
End Sub


This is a procedure to be called in the UpClick and DownClick

Sub gDateTimeEditSpin(controlName As TextBox, UpDown As Integer)

'Dim cdate As String
Dim curPos As Integer
Dim selLen As Integer
Dim Interval As String
Dim formatToUse As String

curPos = controlName.SelStart
selLen = 2



On Error GoTo ErrorRtn

Select Case curPos

Case 0, 1 'Hour
Interval = "h"
curPos = 0
Case 3, 4
Interval = "n"
curPos = 3
Case 6, 7
Interval = "s"
curPos = 6
Case Else
Interval = "None"
End Select

If Interval <> &quot;None&quot; Then
controlName.Text = Format$(DateAdd(Interval, UpDown, controlName.Text)) 'Interval, UpDown, CVDate(cdate)), gDateTimeFormat)
controlName.SelStart = curPos

End If
Exit Sub


ErrorRtn: 'On invalid date/time, exit routine

MsgBox &quot;Invalid date or time - please retype.&quot;, 64
Exit Sub

End Sub 'gDateTimeEditSpin --------------------------

Private Sub UpDown1_DownClick()
Call gDateTimeEditSpin(TxtTime, -1)
End Sub

Private Sub UpDown1_UpClick()
Call gDateTimeEditSpin(TxtTime, 1)
End Sub

And modify to your requirements

Gov
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top