?
Solved

DTPicker format

Posted on 2014-04-27
5
Medium Priority
?
990 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 2000 total points
ID: 40028431
Hi

try

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

HTH

DWE
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

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 …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we 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…
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…
Suggested Courses

807 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