Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Convert time to military time?

How can I convert the current time into military time?
I'd like to show the results in a message box kind of
like:

MsgBox "The military time is: " & strMilitaryTime

The variable strMilitaryTime is a string variable which
is where I want to store the current military time. Oh
ya, I want the military time format to be: "hh:mm:ss",
so 3:42:11 PM should convert to 15:42:11, etc...

Thank you!

Robert Crandal.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Convert time to military time?

You didn't say where the 3:42:11 PM time came from. I'll take a guess at a
TextBox so I think you would be looking for this...

If IsDate(TextBox1.Value) Then
strMilitaryTime = Format(TextBox1.Value, "hh:mm:ss")
MsgBox "The military time is: " & strMilitaryTime
End If

Rick Rothstein (MVP - Excel)




"Robert Crandal" wrote in message
...

How can I convert the current time into military time?
I'd like to show the results in a message box kind of
like:

MsgBox "The military time is: " & strMilitaryTime

The variable strMilitaryTime is a string variable which
is where I want to store the current military time. Oh
ya, I want the military time format to be: "hh:mm:ss",
so 3:42:11 PM should convert to 15:42:11, etc...

Thank you!

Robert Crandal.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Convert time to military time?

Actually, maybe I should fill out that If..Then block...

If IsDate(TextBox1.Value) Then
strMilitaryTime = Format(TextBox1.Value, "hh:mm:ss")
MsgBox "The military time is: " & strMilitaryTime
Else
MsgBox "That is not a correct time value!"
End If

Rick Rothstein (MVP - Excel)




"Rick Rothstein" wrote in message ...

You didn't say where the 3:42:11 PM time came from. I'll take a guess at a
TextBox so I think you would be looking for this...

If IsDate(TextBox1.Value) Then
strMilitaryTime = Format(TextBox1.Value, "hh:mm:ss")
MsgBox "The military time is: " & strMilitaryTime
End If

Rick Rothstein (MVP - Excel)




"Robert Crandal" wrote in message
...

How can I convert the current time into military time?
I'd like to show the results in a message box kind of
like:

MsgBox "The military time is: " & strMilitaryTime

The variable strMilitaryTime is a string variable which
is where I want to store the current military time. Oh
ya, I want the military time format to be: "hh:mm:ss",
so 3:42:11 PM should convert to 15:42:11, etc...

Thank you!

Robert Crandal.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Convert time to military time?

Thank you Rick, your code was sufficient enough for
my needs. It was simpler than I expected, because I saw
other examples online that involved modulus arithmetic.

And BTW, I was actually getting the current time from
the "Time" variable (I think).

Thanks again.

----- Original Message -----
From: "Rick Rothstein"
Newsgroups: microsoft.public.excel.programming
Sent: Monday, April 11, 2011 1:18 AM
Subject: Convert time to military time?


Actually, maybe I should fill out that If..Then block...

If IsDate(TextBox1.Value) Then
strMilitaryTime = Format(TextBox1.Value, "hh:mm:ss")
MsgBox "The military time is: " & strMilitaryTime
Else
MsgBox "That is not a correct time value!"
End If

Rick Rothstein (MVP - Excel)




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
VBA convert Time to Military in the same Column please Steved Excel Programming 4 June 25th 09 01:57 AM
Is there an XLS function to convert std time to Military time? Carl Excel Worksheet Functions 1 May 20th 09 09:48 PM
Convert to Military time? telewats Excel Discussion (Misc queries) 2 March 13th 06 06:17 PM
How do I convert Military Time to minutes? Rachael Excel Worksheet Functions 1 January 6th 05 10:01 PM
Convert to military time - part II Carole O Excel Programming 6 August 14th 04 01:55 AM


All times are GMT +1. The time now is 11:13 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"