我希望能有另一双眼睛来检查我的代码。我正在写一个相对较大的If...Else...语句。看起来一切都编码正确。我已经遍历了整个脚本,但有一个地方一直给我一个"Expected 'End If'",当我觉得我不需要它的时候。
简单地说,我想说的是:如果是废话,那就做这些事情吧。否则,如果是废话,只做其中的一件事。
下面是这段代码:
If(sLogFile <> "" AND nPing <> 1) Then
pingStatus = 1
If(findTag(sLogFile, daRunning) = 1) Then
daStatus = 1
Else If(findTag(sLogFile, daNotRunning) = 1) Then
daStatus = 2
Else
daStatus = 3
End If
If(daStatus = 1 AND findTag(sLogFile, daDataFlowing) = 1) Then
daFlowStatus = 1
Else If(daStatus = 1 AND findTag(sLogFile, daDataNotFlowing) = 1) Then
daFlowStatus = 2
Else If(daStatus = 1 AND findTag(sLogFile, daDataUnchecked) = 1) Then
daFlowStatus = 3
Else If(daStatus <> 1) Then
daFlowStatus = 4
End If
If(findTag(sLogFile, aeRunning) = 1) Then
aeStatus = 1
Else If(findTag(sLogFile, aeNotRunning) = 1) Then
aeStatus = 2
Else
aeStatus = 3
End If
If(findTag(sLogFile, aeDataUnchecked) = 1) Then
aeFlowStatus = 2
Else If(findTag(sLogFile, aeDataExecutionError) = 1) Then
aeFlowStatus = 3
Else If(findTag(sLogFile, aeDataConnectionError) = 1) Then
aeFlowStatus = 4
Else If(findTag(sLogFile, aeTimeStamp) = 1) Then
location = InStr(sLogFile, aeTimeStamp)
leftTrimmedString = LTrim(Mid(sLogFile, (location - 2)))
location = InstrRev(leftTrimmedString, ":")
dateString = Trim(Mid(leftTrimmedString, 1, (location + 5)))
timeDiff = DateDiff("h", dateString, Now)
If(timeDiff > 5) Then
aeFlowStatus = 5
Else
aeFlowStatus = 1
End If
End If
Else If(nPing = 1) Then
pingStatus = 2
If(findTag(sLogFile, aeDataUnchecked) = 1) Then
aeFlowStatus = 2
Else If(findTag(sLogFile, aeDataExecutionError) = 1) Then
aeFlowStatus = 3
Else If(findTag(sLogFile, aeDataConnectionError) = 1) Then
aeFlowStatus = 4
Else If(findTag(sLogFile, aeTimeStamp) = 1) Then
location = InStr(sLogFile, aeTimeStamp)
leftTrimmedString = LTrim(Mid(sLogFile, (location - 2)))
location = InstrRev(leftTrimmedString, ":")
dateString = Trim(Mid(leftTrimmedString, 1, (location + 5)))
timeDiff = DateDiff("h", dateString, Now)
If(timeDiff > 5) Then
aeFlowStatus = 5
Else
aeFlowStatus = 1
End If
End If
End If错误持续发生在主Else If大约2/3的下行路径(Else If(nPing = 1) Then)处。我得到了这一行上的错误。
我尝试通过将End If放在Else IF之上,然后将Else If更改为If,将该块分成两个块。当我这样做的时候,它是有效的,但是我真的不想要两个if语句。
那么,是我搞砸了,还是我的解释器有问题?
https://stackoverflow.com/questions/38254996
复制相似问题