下面是我编写的代码,但是我一直对我添加注释的行感到不解,并且只是该行。我已经评论了所有其他的路线,并将其隔离为问题路线,但是对于我的生活以及我已经完成的一小时或更多的研究,我无法弄清楚问题所在。这可能是一个非常明显的,但我真的被卡住了,这让我疯狂。从另一个函数内部调用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