Results 1 to 10 of 10
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm (again) looking for a way to allow a user to put in a data & time (actually: a start-date & time and an end-date & time...)

    In the past I fooled around with DTPICKER but that's for dates only. I scanned the net a bit but couldn't find anything nice.

    I'm thinking about a dialog that looks like the one one gets when we set/change the Windows date and time (double click on the time in your lower-right corner of the screen and you know what I mean... ).

    Is that available via API-calls and/or has this been programmed by someone ever?

  2. #2
    New Lounger
    Join Date
    Dec 2009
    Location
    Redmond WA
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I don't know of any third party control or API call for that one. I use two text boxes (one for the date, one for the time) for the start, and two for the end.
    I put VCR controls by each of them to control what goes into the boxes.
    [date text box] -M -D Today +D +M (five buttons) [time text box] -H -M Now +M +H (five more buttons)
    This way the user cant goof it up.

    Willie McClure
    Willie McClure
    www.datarim.com

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by ErikJan View Post
    I'm (again) looking for a way to allow a user to put in a data & time (actually: a start-date & time and an end-date & time...)

    In the past I fooled around with DTPICKER but that's for dates only. I scanned the net a bit but couldn't find anything nice.

    I'm thinking about a dialog that looks like the one one gets when we set/change the Windows date and time (double click on the time in your lower-right corner of the screen and you know what I mean... ).

    Is that available via API-calls and/or has this been programmed by someone ever?
    Does the following help?
    Code:
    Public Sub TimeInput()
    Dim ti As String
    ReQuery:
    	ti = InputBox("Input the time as 4 characters of a 24 hour clock.", _
     	"Time", "0000")
    	If Len(ti) <> 4 Then GoTo FormatFault
    	If Val(Left(ti, 2)) > 24 Then GoTo FormatFault
    	If Val(Right(ti, 2)) > 59 Then GoTo FormatFault
    	If Val(ti) > 2400 Then GoTo FormatFault
    	
    	' Combine with date from DTPICKER
    	
    Exit Sub
    FormatFault:
    	MsgBox "The time input of """ & ti & """ is invalid.", vbExclamation, "Time"
    	GoTo ReQuery
    End Sub
    Regards
    Don

  4. #4
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    The following function can be added to the results of DTPICKER in a manner similar to:

    MyDate = DTPICKER...
    StartTime = MyDate + TimeInput
    Code:
    Public Function TimeInput() As Double
    Dim ti As String
    ReQuery:
    	ti = InputBox("Input the time as 4 characters of a 24 hour clock.", _
    	"Time", "0000")
    	If Len(ti) <> 4 Then GoTo FormatFault
    	If Val(Left(ti, 2)) > 24 Then GoTo FormatFault
    	If Val(Right(ti, 2)) > 59 Then GoTo FormatFault
    	If Val(ti) > 2400 Then GoTo FormatFault
    	
    	TimeInput = Left(ti, 2) / 24 + Right(ti, 2) / (24 * 60)
    	
    Exit Function
    FormatFault:
    	MsgBox "The time input of """ & ti & """ is invalid.", vbExclamation, "Time"
    	GoTo ReQuery
    End Function
    Regards
    Don

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by wdwells View Post
    The following function can be added to the results of DTPICKER in a manner similar to:

    MyDate = DTPICKER...
    StartTime = MyDate + TimeInput
    Code:
    Public Function TimeInput() As Double
    Dim ti As String
    ReQuery:
    	ti = InputBox("Input the time as 4 characters of a 24 hour clock.", _
    	"Time", "0000")
    	If Len(ti) <> 4 Then GoTo FormatFault
    	If Val(Left(ti, 2)) > 24 Then GoTo FormatFault
    	If Val(Right(ti, 2)) > 59 Then GoTo FormatFault
    	If Val(ti) > 2400 Then GoTo FormatFault
    	
    	TimeInput = Left(ti, 2) / 24 + Right(ti, 2) / (24 * 60)
    	
    Exit Function
    FormatFault:
    	MsgBox "The time input of """ & ti & """ is invalid.", vbExclamation, "Time"
    	GoTo ReQuery
    End Function
    OK, so this would allow me to create something like the attached then, right? (still strange this WinXP dialog is not possible via API calls... looks nice enough to me)

    So now... how do I get the DTPicker in a dialog again?? I think this is an old one and couldn't find in my control-box. Any examples and/or documentation out there??
    Attached Images Attached Images

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If you mean the Control Toolbox toolbar in Word or Excel: click the More Controls button (usually the last one).
    If you mean the Toolbox for a userform in the Visual Basic Editor: right-click the Toolbox and select More Controls from the popup menu.

  7. #7
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    If you mean the Control Toolbox toolbar in Word or Excel: click the More Controls button (usually the last one).
    If you mean the Toolbox for a userform in the Visual Basic Editor: right-click the Toolbox and select More Controls from the popup menu.
    "Element not found"...? (in VBA)

  8. #8
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by ErikJan View Post
    "Element not found"...? (in VBA)
    Does this page help?
    Regards
    Don

  9. #9
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by ErikJan View Post
    "Element not found"...? (in VBA)
    If you are working in Excel the attached example should help. You will need mscal.ocx which can be found here.
    Attached Files Attached Files
    Regards
    Don

  10. #10
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by wdwells View Post
    If you are working in Excel the attached example should help. You will need mscal.ocx which can be found here.
    That works... I'll try to 'work-in' some times according to previous suggestions

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •