Solved

DTPicker format

Posted on 2014-04-27
5
637 Views
Last Modified: 2014-04-28
In vb6 I am using DTPicker and set to time format.  The format is currently 01:00:00AM and I would like to change it to 01:00 AM

How do I accomplish that?
0
Comment
Question by:al4629740
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:jkaios
ID: 40026531
As far as I know that control always shows the second portion of the time.  And when setting the properties .Format = dtpCustom and .CustomFormat = "hh:mm AMPM" the result will be obscure.

An alternative is to use a standard text box and only display the hour and minute portion of the time.
0
 
LVL 1

Expert Comment

by:dwe0608
ID: 40028178
Hi - using the properties of the control - you can set the format to the time format as you want.

assuming you have a Date Time Picker control called "DTPicker1" you set the format through the properties, or through code as follows:

With DTPicker1
  .Format = dtpCustom
  .CustomFormat = "hh:mm tt"
End with

that will return a time formatted like "01:00 AM"

With the custom format = HH will format hours for 24hour time and hh will be in 12 hour format.

HTH

DWE
0
 
LVL 12

Expert Comment

by:jkaios
ID: 40028379
Yup, you got it right, DWE.  I never thought of the "tt" part, tsk, tsk... ;-)
0
 

Author Comment

by:al4629740
ID: 40028424
When setting it to  .Format = dtpCustom
.CustomFormat = "hh:mm tt"

I notice a new problem.  In custom format it allows a dropdown menu calendar.  How do I prevent that and only allow the time for the day.
0
 
LVL 1

Accepted Solution

by:
dwe0608 earned 500 total points
ID: 40028431
Hi

try

    With DTPicker1
        .Format = dtpCustom
        .CustomFormat = "hh:mm tt"
        .UpDown = True
    End With

HTH

DWE
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now