Solved

DTPicker format

Posted on 2014-04-27
5
790 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 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…

737 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