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.
Printable View
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.
Try something like this:
Note: The Input isn't checked to be a valid time!!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
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?
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
I didn't use a TextBox, I used an Inputbox instead, TimeInput gets the Time-Variable out of the String("Text") from the Inputbox.