Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Entering military time into a userform

you're welcome and thanks for the feedback

"WillRn" wrote in message
...
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" wrote in message
...
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
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
Converting Standard Time to Military Time in Excel mtvschultz Excel Discussion (Misc queries) 3 May 5th 23 11:42 AM
Is there an XLS function to convert std time to Military time? Carl Excel Worksheet Functions 1 May 20th 09 09:48 PM
Entering Military Time Karen Excel Worksheet Functions 10 December 8th 08 03:21 PM
formula for converting military time to standard time, etc Pattio Excel Discussion (Misc queries) 8 February 17th 08 01:12 AM
Show timesheet time in and out in regular time versus military tim John Excel Worksheet Functions 1 November 11th 05 05:14 AM


All times are GMT +1. The time now is 04:17 AM.

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

About Us

"It's about Microsoft Excel"