Solved

From To for selecting times

Posted on 2014-04-21
7
164 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

860 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