Results 1 to 4 of 4

Thread: Get Datepicker am pm time to a 24 time in a variable vb6

  1. #1

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Get Datepicker am pm time to a 24 time in a variable vb6

    Date picker displays 7:30 Pm
    How can i get the time to a 24 hour variable ? using vb6
    eg
    Dim mytime as date
    mytime = 1730
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Get Datepicker am pm time to a 24 time in a variable vb6

    date/time variables are not 24 hour nor 12 hour formats. They are binary data.

    If you want to display that binary data in 24 hour format, use the Format() function. If you are converting some string to a date/time variable, do so with the CDate() function to get the string into that binary data.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: Get Datepicker am pm time to a 24 time in a variable vb6

    Also note that 1730 is not a time it is a number and if you place that number in a date var what you will get is not anywhere near 19:30 which is what 7:30 Pm would be("17:30" would be 5:30 PM)

    If memory serves you were shown just a few days ago ho to set up a date and in that thread you had did the same thing where you tried to set a date using a numeric value that you thought was a time and was getting 9/25/1904 as your date.

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,624

    Re: Get Datepicker am pm time to a 24 time in a variable vb6

    Is this what you are looking for?

    Code:
    Private Sub Form_Load()
        With DTPicker1
            .Format = dtpCustom
            .CustomFormat = "dd/MMM/yyyy HH:mm"
            .Value = Now
        End With
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width