Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Time in a TextBox


I would like the code below to put the current time (in 24 hour format) in
TextBox3. So how can I modify this so I only get the time and not the date
and have the displayed time in the 24 hour format (18:45 for 6:45pm)

Private Sub TextBox1_Change()
TextBox3.Value = Now()
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Time in a TextBox


Thank you sir

"Patrick Molloy" wrote in message
...

Private Sub TextBox1_Change()
TextBox3.Value =format$( Now(),"HH:MM")
End Sub


"Patrick C. Simonds" wrote in message
...
I would like the code below to put the current time (in 24 hour format)
in TextBox3. So how can I modify this so I only get the time and not the
date and have the displayed time in the 24 hour format (18:45 for 6:45pm)

Private Sub TextBox1_Change()
TextBox3.Value = Now()
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Time in a TextBox


There is also a Time function in VB, but you would still need to use the
Format function to get 24-hour time (unless your computer's local setting
for time is already formatted as 24-hour time)...

TextBox3.Value = Format$(Time, "hh:mm")

Note that I did not use Time() for the function call as the parentheses on a
function call are not needed when they contain no arguments between them.
So, your Now() function call would also work just as well if you used Now
instead (this is different than function calls in formulas on the worksheet
itself where the parentheses are always needed).

--
Rick (MVP - Excel)


"Patrick Molloy" wrote in message
...

Private Sub TextBox1_Change()
TextBox3.Value =format$( Now(),"HH:MM")
End Sub


"Patrick C. Simonds" wrote in message
...
I would like the code below to put the current time (in 24 hour format)
in TextBox3. So how can I modify this so I only get the time and not the
date and have the displayed time in the 24 hour format (18:45 for 6:45pm)

Private Sub TextBox1_Change()
TextBox3.Value = Now()
End Sub



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
Time in a TextBox Patrick Molloy Excel Programming 0 July 2nd 09 04:54 PM
TextBox to time Patrick C. Simonds Excel Programming 7 January 14th 09 09:19 PM
Textbox for accepting TIME WLMPilot Excel Programming 16 January 8th 08 06:58 PM
How do I format a textbox with time Jennifer Excel Programming 1 July 13th 06 06:27 AM
TextBox and Time Soniya[_4_] Excel Programming 2 December 3rd 05 07:17 AM


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