A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

how do i create a form so that a selected check box shows time



 
 
Thread Tools Display Modes
  #1  
Old October 19th, 2006, 05:33 PM posted to microsoft.public.word.tables
JFR
external usenet poster
 
Posts: 6
Default how do i create a form so that a selected check box shows time

I would like to create a form to use for recording an ongoing series of
events. The form would have a check box that when checked would display
current time (start of event). Another check box when checked would also
display the current time (end of event). Finally the elapsed time
(difference between start and end of event would be displayed.

Thanx
  #2  
Old October 19th, 2006, 09:32 PM posted to microsoft.public.word.tables
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
Default how do i create a form so that a selected check box shows time

I would create a userform with two checkboxes chkStart and chkEnd, three
textboxes txtStart, txtEnd and txtElapsed and a command button cmdClear

Then use the following code in the UserForm:

Private Sub chkEnd_Click()
Dim Hours As Long, Minutes As Long, Seconds As Long, Elapsed As Long
txtEnd.Text = Format(Now, "HH:mm:ss")
If chkEnd.Value = True Then
Elapsed = DateDiff("s", txtStart, txtEnd)
Else
Exit Sub
End If
Hours = Int(Elapsed / 3600)
Minutes = Int((Elapsed Mod 3600) / 60)
Seconds = Elapsed Mod 60
txtElapsed.Text = Format(Hours, "00") & ":" & Format(Minutes, "00") & ":" &
Format(Seconds, "00")
End Sub

Private Sub chkStart_Click()
txtStart.Text = Format(Now, "HH:mm:ss")
End Sub

Private Sub cmdClear_Click()
chkStart.Value = False
txtStart.Text = ""
chkEnd.Value = False
txtEnd.Text = ""
txtElapsed.Text = ""
End Sub

When you check the chkStart checkbox, the start time will be displayed in
the txtStart textbox as HH:mm:ss and when the chkEnd checkbox is checked,
the txtEnd textbox will display the finish time as HH:mm:ss and the
txtElapsed textbox will display the elapese time, also in HH:mm:ss format.

The cmdClear button will remove all data from the form so that the process
can be repeated.

If you don't know how to create a userform, see the necessary parts of the
article "How to create a Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"JFR" wrote in message
...
I would like to create a form to use for recording an ongoing series of
events. The form would have a check box that when checked would display
current time (start of event). Another check box when checked would also
display the current time (end of event). Finally the elapsed time
(difference between start and end of event would be displayed.

Thanx



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.