下面是我編寫的代碼,但是我一直對我添加註釋的行感到不解,並且只是該行。我已經評論了所有其他的路線,並將其隔離爲問題路線,但是對於我的生活以及我已經完成的一小時或更多的研究,我無法弄清楚問題所在。這可能是一個非常明顯的,但我真的被卡住了,這讓我瘋狂。從另一個函數內部調用VBA函數
不管怎樣,代碼是用來取含換擋時間和語言能力數據的範圍,並顯示有多少人有特定的語言如何都可以在給定的時間段(The_Time在下面的代碼)
任何幫助將不勝感激!
Function ReturnAvailability(The_Time As String, The_Info As Range)
Dim The_Lang As String
Dim The_Shift_Start As String
Dim The_Shift_End As String
Dim stGotIt As String
Dim stCell As Integer
Dim Counter As Integer
Counter = 0
For Each r In The_Info.Rows
For Each c In r.Cells
stCell = c.Value
If InStr(stCell, "Eng") > 0 Then
The_Lang = "Eng"
ElseIf InStr(c, ":") > 0 Then
stGotIt = StrReverse(c)
stGotIt = Left(c, InStr(1, c, " ", vbTextCompare))
The_Shift_End = StrReverse(Trim(stGotIt))
stGotIt = Left(The_Shift, InStr(1, The_Shift, " ", vbTextCompare))
The_Shift_Start = stGotIt
stCell = ReturnAvailabilityEnglish(The_Time, The_Shift_Start, The_Shift_End) ' this is the line causing the error
End If
Next c
Next r
ReturnAvailability = Counter
End Function
Function ReturnAvailabilityEnglish(The_Time As String, The_Shift_Start As String, The_Shift_End As String)
Dim Time_Hour As Integer
Dim Time_Min As Integer
Dim Start_Hour As Integer
Dim Start_Min As Integer
Dim End_Hour As Integer
Dim End_Min As Integer
Dim Available As Integer
Available = 13
Time_Hour = CInt(Left(The_Time, 2))
Time_Min = CInt(Right(The_Time, 2))
Start_Hour = CInt(Left(The_Shift_Start, 2))
Start_Min = CInt(Right(The_Shift_Start, 2))
End_Hour = CInt(Left(The_Shift_End, 2))
End_Min = CInt(Right(The_Shift_End, 2))
If Start_Hour <= Time_Hour And Start_Min <= Time_Min Then
If End_Hour > Time_Hour And End_Min > Time_Min Then
Available = 1
Else
Available = 0
End If
End If
ReturnAvailabilityEnglish = Available
End Function
感謝, 達拉赫Ĵ
哪一行導致錯誤?它是編譯錯誤還是運行時錯誤? – 2010-11-19 15:15:13
對不起,評論加入了 – 2010-11-19 17:57:02
什麼是錯誤? – BenV 2010-11-19 18:24:44