Solved

From To for selecting times

Posted on 2014-04-21
7
163 Views
Last Modified: 2014-04-21
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?
0
Comment
Question by:al4629740
  • 4
  • 3
7 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 40013272
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
 

Author Comment

by:al4629740
ID: 40013285
DTPicker has a calendar that pops up.  Is it possible to change the format to Time?
0
 

Author Comment

by:al4629740
ID: 40013286
Nevermind.  Found it
0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40013359
Well done. Pleased that you are OK now.
0
 

Author Comment

by:al4629740
ID: 40013414
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40013527
The number is in days, or part days.

How do you need to see it?
0
 

Author Comment

by:al4629740
ID: 40013704
in Hours
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question