Solved

DTPicker format

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

Suggested Solutions

Title # Comments Views Activity
Notepad++ how to remove delimiter : from beggning of the line? 3 126
Advice in Xamarin 21 109
RUNRMTCMD from AS/400 13 89
checkbox to hide entire section 10 58
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…
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…

756 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