|
-
Dec 4th, 2000, 07:57 AM
#1
Thread Starter
New Member
I need code to "fit" into what I already have.
The code that I have, along with its userform, work's great if you are calculating time during one work day. In other words, into work at 8:00am and out at 4:35pm (16:35). But if the time "in" is 16:40 and the time "out" is 00:15, then the code does not work.
Since I have the total time worked going to textbox8, and then automatically pasted to an Excel spreadsheet, I need to know the code that will work within what I already have. (I don't know how to do this, I haven't been able to figure the coding out.)
Here is the code for the first two "in" and "out" textbox's and the code that calculates the amount of time worked. The amount of time worked goes into Textbox8. [I didn't leave it here, but I also use the same following code for the rest of the project, which is appointments in and out, projects in and out, misc in and out.]
Private Sub Calbtn_Enter()
Dim IntIn%, intOut%, intLength%
Dim intError As Integer
'check value in textbox1 to make sure it is valid time
intError = Validate_Time(TextBox1.Text)
If intError <> 0 Then
MsgBox "The ""Time In"" entry is formatted incorrectly. " & _
"Use ""hh:mm"" format. Please try again."
TextBox1.SetFocus
intLength% = Len(TextBox1.Text)
TextBox1.SelStart = 0
TextBox1.SelLength = intLength%
Exit Sub
End If
IntIn = Format$(TextBox1, "h") * 60 + Format$(TextBox1, "nn")
'check value in textbox2 to make sure it is valid time
intError = Validate_Time(TextBox2.Text)
If intError <> 0 Then
MsgBox "The ""Time Out"" entry is formatted incorrectly. " & _
"Use ""hh:mm"" format. Please try again."
TextBox2.SetFocus
intLength% = Len(TextBox2.Text)
TextBox2.SelStart = 0
TextBox2.SelLength = intLength%
Exit Sub
End If
intOut = Format$(TextBox2, "h") * 60 + Format$(TextBox2, "nn")
TextBox8 = (intOut - IntIn)/60
......From this point, the total time worked is pasted into an Excel spreadsheet with the following code.
strDayofWeek = ComboBox1.Value
Select Case strDayofWeek 'copies day choosen and paste the total time to worksheet Time
Case "Monday"
Worksheets("timecard").Cells(13, 2).Value = CSng(TextBox8.Value)
Case "Tuesday"
Worksheets("timecard").Cells(13, 3).Value = CSng(TextBox8.Value) etc, etc, etc.
As you can see, I really need help with code that will work with what I already have. I believe we're looking at an "if" statement of sorts, but I don't know what code.
Thank You.
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
|