|
-
Nov 25th, 2010, 03:25 AM
#1
Thread Starter
New Member
Time Compare
I looked thro many books and here, but can't find an answer to>
How can I write a sub that looks at a time ("hh,mm, AM/PM) that I input into a text box, compare with PC time and provide a label text output?
Thanks for any help.
-
Nov 25th, 2010, 04:09 AM
#2
Re: Time Compare
Try something like this:
Code:
Public Sub Timecheck()
Dim TimePC As Date
Dim TimeInput As Date
Dim Text As String
TimePC = Time()
Text = InputBox("Time:", "Input", 200, 200)
TimeInput = TimeValue(Text)
MsgBox "TimeDifference " & Format(TimeInput - TimePC, "hh:mm"), vbOKOnly, "OutValue"
End Sub
Note: The Input isn't checked to be a valid time!!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Nov 25th, 2010, 04:26 AM
#3
Re: Time Compare
Using a textbox to input a time (or date) value is not a wise move, because it is prone to errors and bugs.
For an explanation of why, see the article Why are my dates not working properly? from our Classic VB FAQs (in the FAQ forum)
For information about the kind of controls you should be using, see the article What controls can I use to input a date/time?
-
Nov 25th, 2010, 04:35 AM
#4
Thread Starter
New Member
Re: Time Compare
Many thanks, having read thro my original post I don't think I made it clear, well I am 66 so the old grey matter is slow. I need an output when the PC and the input time coincides, i,e to start a process off.
I take it that TimeInput is the name given to a textbox?
Thanks
-
Nov 25th, 2010, 04:39 AM
#5
Re: Time Compare
I didn't use a TextBox, I used an Inputbox instead, TimeInput gets the Time-Variable out of the String("Text") from the Inputbox.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|