LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Force a Date variable to store a time value

I want my user to enter the time of day into an input box.

My code looks like this:

Dim CollectionTime As Date
CollectionTime = _
InputBox("Enter Collection Time", "Collection Time", Time)

If I run the macro and accept the input box default, the variable
CollectionTime saves a time value in the format "12:00:00 AM". But if I
enter the time in the format "1200" (no quotes), then CollectionTime
stores a seemingly arbitrary date value. It works if I enter a value as
"12:00" (with the colon), but I don't want to waste my users' time by
making them enter the colon.

I've tried the Help files, I've tried the Format function, and I've
Googled it. This is probably the most retarded question ever, but how do
I force a Date variable to store a value like "1500" as a time value?

As always, thanks a bunch.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
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
STORE THE DATE & TIME THE VALUE HAS CHANGED IN A CELL Asoka Walpitagama - Brandix College IT Excel Discussion (Misc queries) 1 January 29th 09 12:12 PM
worksheet name store in a variable Steve P[_2_] Excel Programming 3 February 14th 07 05:54 AM
store variable keen learner Excel Programming 9 March 8th 06 02:26 PM
How to store text to variable jafery Excel Programming 0 September 29th 05 10:18 AM
Store variable value for Chart Al Jager Excel Programming 1 February 19th 04 10:58 AM


All times are GMT +1. The time now is 06:30 PM.

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"