Chinaunix首页 | 论坛 | 博客
  • 博客访问: 30479465
  • 博文数量: 708
  • 博客积分: 12163
  • 博客等级: 上将
  • 技术积分: 8240
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-04 20:59
文章分类

全部博文(708)

分类: Java

2009-11-27 15:35:08

 
考勤时间
09:17-17:39
 
 

Private Sub Workbook_Open()
    Dim total As Double
    For i = 0 To 30
   
        Dim start As Integer
        start = 18
       
        Dim dayTime As String
        dayTime = Cells(start + i, 21)
       
        If (Len(dayTime) = 11) Then
       
            Dim startStr As String
            startStr = Left(dayTime, 5)
            Dim startTime As Date
            startTime = CDate(startStr)
           
            Dim endStr As String
            endStr = Right(dayTime, 5)
            Dim endTime As Date
            endTime = CDate(endStr)
           
            If (endTime > CDate("17:30")) Then
                endTime = CDate("16:30")
            End If
           
            dayTime = Application.WorksheetFunction.Text(endTime - startTime, "h:mm")
           
            Dim minuteStr As String
            minuteStr = Right(dayTime, 2)
            Dim minuteInt As Integer
            minuteInt = CInt(minuteStr)
           
            Dim minuteDouble As Double
            If minuteInt - 45 > 0 Then
                minuteDouble = 0.75
            ElseIf minuteInt - 30 > 0 Then
                minuteDouble = 0.5
            ElseIf minuteInt - 15 > 0 Then
                minuteDouble = 0.25
            Else
                minuteDouble = 0
            End If
            Dim hourStr As String
            hourStr = Left(dayTime, 1)
            Dim hourInt As Integer
            hourInt = CInt(hourStr)
           
            Dim dayDouble As Double
            dayDouble = hourInt + minuteDouble
            total = total + dayDouble
           
        End If
    Next i
    MsgBox total
   
End Sub
阅读(1764) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~