From To for selecting times

I am making a form in vb6.  Using DTPicker or anything else, what is the best method to have a dropdown box for selecting time?

I want to have a FROM and TO for selecting time.  And then I would like to calculate the time in a third textbox.

Any ideas?
al4629740Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
GrahamSkanConnect With a Mentor RetiredCommented:
The best method will depend on many factors. Here is one way:
Private Sub Command1_Click()
    Text1.Text = DTPicker1.Value
End Sub
Private Sub Command2_Click()
    Text2.Text = DTPicker1.Value
End Sub

Private Sub Text1_Change()
    If IsDate(Text2) And IsDate(Text1) Then
        Text3 = CDate(Text2) - CDate(Text1)
    End If
End Sub

Private Sub Text2_Change()
    If IsDate(Text2) And IsDate(Text1) Then
        Text3 = CDate(Text2) - CDate(Text1)
    End If
End Sub

Open in new window

0
 
al4629740Author Commented:
DTPicker has a calendar that pops up.  Is it possible to change the format to Time?
0
 
al4629740Author Commented:
Nevermind.  Found it
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
GrahamSkanRetiredCommented:
Well done. Pleased that you are OK now.
0
 
al4629740Author Commented:
When I run the code, my output is always an odd number, such as

11:00:00 PM to 12:00:00 PM =  -0.91666666666

How do I get it to give me a number like 1 or 1.5
0
 
GrahamSkanRetiredCommented:
The number is in days, or part days.

How do you need to see it?
0
 
al4629740Author Commented:
in Hours
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.