+ Reply to Thread
Results 1 to 4 of 4

Entering military time into a userform

  1. #1
    WillRn
    Guest

    Entering military time into a userform

    I have a textbox on a userform for a military time (24 hour clock). The
    trouble is that I can't seem to get any format codes to work.

    I just want the user to be able to input a 4 digit time and have the input
    display in the textbox as a 24 hour short time.

    For example: User inputs 1345 and then textbox displays 13:45. The value
    then postd to the spreadsheet would be 13:45.

    I know this is probably simple, but I can't seem to get anything to work.

    WillRn

  2. #2
    JulieD
    Guest

    Re: Entering military time into a userform

    Hi WillRn

    Something along the lines of

    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Hr = Int(Me.TextBox1 / 100)
    Min = Me.TextBox1 Mod 100
    Sec = 0
    Me.TextBox1 = Format(TimeSerial(Hr, Min, Sec), "hh:mm")
    Range("A1").Value = TimeSerial(Hr, Min, Sec)
    Range("a1").NumberFormat = "hh:mm"
    End sub

    Cheers
    JulieD

    "WillRn" <[email protected]> wrote in message
    news:[email protected]...
    >I have a textbox on a userform for a military time (24 hour clock). The
    > trouble is that I can't seem to get any format codes to work.
    >
    > I just want the user to be able to input a 4 digit time and have the input
    > display in the textbox as a 24 hour short time.
    >
    > For example: User inputs 1345 and then textbox displays 13:45. The value
    > then postd to the spreadsheet would be 13:45.
    >
    > I know this is probably simple, but I can't seem to get anything to work.
    >
    > WillRn




  3. #3
    WillRn
    Guest

    Re: Entering military time into a userform

    Thank You Julie! It was just what I needed.

    Much Thanks,

    WillRn

    "JulieD" wrote:

    > Hi WillRn
    >
    > Something along the lines of
    >
    > Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    > Hr = Int(Me.TextBox1 / 100)
    > Min = Me.TextBox1 Mod 100
    > Sec = 0
    > Me.TextBox1 = Format(TimeSerial(Hr, Min, Sec), "hh:mm")
    > Range("A1").Value = TimeSerial(Hr, Min, Sec)
    > Range("a1").NumberFormat = "hh:mm"
    > End sub
    >
    > Cheers
    > JulieD
    >
    > "WillRn" <[email protected]> wrote in message
    > news:[email protected]...
    > >I have a textbox on a userform for a military time (24 hour clock). The
    > > trouble is that I can't seem to get any format codes to work.
    > >
    > > I just want the user to be able to input a 4 digit time and have the input
    > > display in the textbox as a 24 hour short time.
    > >
    > > For example: User inputs 1345 and then textbox displays 13:45. The value
    > > then postd to the spreadsheet would be 13:45.
    > >
    > > I know this is probably simple, but I can't seem to get anything to work.
    > >
    > > WillRn

    >
    >
    >


  4. #4
    JulieD
    Guest

    Re: Entering military time into a userform

    you're welcome and thanks for the feedback

    "WillRn" <[email protected]> wrote in message
    news:[email protected]...
    > Thank You Julie! It was just what I needed.
    >
    > Much Thanks,
    >
    > WillRn
    >
    > "JulieD" wrote:
    >
    >> Hi WillRn
    >>
    >> Something along the lines of
    >>
    >> Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    >> Hr = Int(Me.TextBox1 / 100)
    >> Min = Me.TextBox1 Mod 100
    >> Sec = 0
    >> Me.TextBox1 = Format(TimeSerial(Hr, Min, Sec), "hh:mm")
    >> Range("A1").Value = TimeSerial(Hr, Min, Sec)
    >> Range("a1").NumberFormat = "hh:mm"
    >> End sub
    >>
    >> Cheers
    >> JulieD
    >>
    >> "WillRn" <[email protected]> wrote in message
    >> news:[email protected]...
    >> >I have a textbox on a userform for a military time (24 hour clock). The
    >> > trouble is that I can't seem to get any format codes to work.
    >> >
    >> > I just want the user to be able to input a 4 digit time and have the
    >> > input
    >> > display in the textbox as a 24 hour short time.
    >> >
    >> > For example: User inputs 1345 and then textbox displays 13:45. The
    >> > value
    >> > then postd to the spreadsheet would be 13:45.
    >> >
    >> > I know this is probably simple, but I can't seem to get anything to
    >> > work.
    >> >
    >> > WillRn

    >>
    >>
    >>




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1