首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >If Else语句给出我缺少End If语句的错误

If Else语句给出我缺少End If语句的错误
EN

Stack Overflow用户
提问于 2016-07-08 04:48:11
回答 0查看 1.8K关注 0票数 0

我希望能有另一双眼睛来检查我的代码。我正在写一个相对较大的If...Else...语句。看起来一切都编码正确。我已经遍历了整个脚本,但有一个地方一直给我一个"Expected 'End If'",当我觉得我不需要它的时候。

简单地说,我想说的是:如果是废话,那就做这些事情吧。否则,如果是废话,只做其中的一件事。

下面是这段代码:

代码语言:javascript
复制
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语句。

那么,是我搞砸了,还是我的解释器有问题?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38254996

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档