热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如果没有结束则阻止if和Next没有结束

如何解决《如果没有结束则阻止if和Next没有结束》经验,为你挑选了1个好方法。

对于这个if-without-end问题,如果你使用else if(两个单词),每个人都 if需要相应的end if.您应该使用elseif(一个单词)变体来编码.看看这两者之间的区别:

if a = 1 then          if a = 1 then
    b = 2                  b = 2
else                   elseif a = 2 then 
    if a = 2 then          b = 1
        b = 1          else
    else                   b = 0
        b = 0          end if
    end if
end if

对于这个next-without-for问题,你应该end if用来关闭你的if陈述,而不仅仅是end你现在拥有的陈述:

If GroupChoice = 1 Then
    For row = 1 To 15
       group1Late = "A" & row
       MEG1Late = "AD" & row
       If ActiveSheet.Cells(row, 1).Value = "" Then
           Range("group1Late") = StudentName
           Range("MEG1Late") = MEGChoice
       End If ' <-- HERE '
    Next
End If        ' <-- AND HERE '

End 本身用于停止程序.

我怀疑的错误是由不均衡性你造成的for-next,并if-end if,VB是看到他们交错,因为没有end if那么它假定谈到某处next.



1> paxdiablo..:

对于这个if-without-end问题,如果你使用else if(两个单词),每个人都 if需要相应的end if.您应该使用elseif(一个单词)变体来编码.看看这两者之间的区别:

if a = 1 then          if a = 1 then
    b = 2                  b = 2
else                   elseif a = 2 then 
    if a = 2 then          b = 1
        b = 1          else
    else                   b = 0
        b = 0          end if
    end if
end if

对于这个next-without-for问题,你应该end if用来关闭你的if陈述,而不仅仅是end你现在拥有的陈述:

If GroupChoice = 1 Then
    For row = 1 To 15
       group1Late = "A" & row
       MEG1Late = "AD" & row
       If ActiveSheet.Cells(row, 1).Value = "" Then
           Range("group1Late") = StudentName
           Range("MEG1Late") = MEGChoice
       End If ' <-- HERE '
    Next
End If        ' <-- AND HERE '

End 本身用于停止程序.

我怀疑的错误是由不均衡性你造成的for-next,并if-end if,VB是看到他们交错,因为没有end if那么它假定谈到某处next.


推荐阅读
author-avatar
嘻嘻2502891803
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有