Closed Thread
Results 1 to 3 of 3

Format a Userform textbox to Military time

  1. #1
    Christy
    Guest

    Format a Userform textbox to Military time

    I have a user form with 5 textboxes linked to cells. I can't seem to get the
    textboxes to show the entry in Military time. It keeps changing to decimal.
    The time shows up correctly in the cell.

    any help would be greatly appreciated.

    Christy

  2. #2
    Nick Hebb
    Guest

    Re: Format a Userform textbox to Military time

    Try something like:

    Private Sub UserForm_Initialize()

    Dim ws As Worksheet
    Set ws = ActiveSheet

    TextBox1.Text = Format$(ws.Range("A1"), "H:mm")

    Set ws = Nothing

    End Sub

    Note: the capital 'H' in the format string is important. If you use a
    lowercase 'h' then you'll get a 12-hour clock value.


  3. #3
    Christy
    Guest

    Re: Format a Userform textbox to Military time

    Thanks Nick, I will try that!

    Christy


    "Nick Hebb" wrote:

    > Try something like:
    >
    > Private Sub UserForm_Initialize()
    >
    > Dim ws As Worksheet
    > Set ws = ActiveSheet
    >
    > TextBox1.Text = Format$(ws.Range("A1"), "H:mm")
    >
    > Set ws = Nothing
    >
    > End Sub
    >
    > Note: the capital 'H' in the format string is important. If you use a
    > lowercase 'h' then you'll get a 12-hour clock value.
    >
    >


Closed 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