Solved

DTPicker format

Posted on 2014-04-27
5
816 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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