Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default 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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
military format of time awais Excel Discussion (Misc queries) 1 May 20th 08 01:34 PM
i want to use military format for time e.g. 07:00 as 0700 awais Excel Worksheet Functions 2 May 18th 08 04:48 PM
getting military time format within excel dgarrison Excel Discussion (Misc queries) 3 December 25th 05 11:47 PM
Entering military time into a userform WillRn Excel Programming 3 March 14th 05 04:25 PM
TextBox in UserForm with 24h time format Mika Excel Programming 1 February 1st 05 08:45 PM


All times are GMT +1. The time now is 09:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"