怎么退出当前循环,进行下一次循环

friskay 2004-12-07 02:37:09
while中 能不能退出当前循环,进行下一次循环
比如:
while (i=5 or j=1)

if j=0 '当j=0 时
'******进行下一次循环,不执行下个那个pf函数,
end if
pf()
i++
end while

请问有没有什么办法
...全文
597 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
friskay 2004-12-07
  • 打赏
  • 举报
回复
用了 allanli(若尘) 做法 给了50分

作完了之后看到了 hbxtlhx(下着春雨的天)的, 感觉应该是正确的,给42分

说的正确的,原创都有分

错误的没分,不是第一个写出来的也没有分
friskay 2004-12-07
  • 打赏
  • 举报
回复
不知道这样给分合理不
friskay 2004-12-07
  • 打赏
  • 举报
回复
楼上正解,一会给分
北京的雾霾天 2004-12-07
  • 打赏
  • 举报
回复
大家不要再说
break, continue
之类的关键字了

都是C#里的,和VB.NET不一样的!!!

参见如下:

不同语言中的关键字的比较
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vsintro7/html/vxorilanguageequivalentskeywords.asp

MSDN:

替换 Continue 语句
Visual Basic .NET 不支持 Visual Basic 早期版本中的 Continue 语句。但可以通过在 Loop 语句上添加语句标签,并从循环中分支到该语句来实现相同的功能:

Dim LoopCounter As Integer = 0
Do While LoopCounter < 100
LoopCounter += 1
Dim SkipToNextIteration As Boolean ' Local to this loop.
' Processing, which might change value of SkipToNextIteration.
If SkipToNextIteration = True Then GoTo EndOfLoop
' More processing if SkipToNextIteration was still False.
EndOfLoop: Loop ' Acts like Continue.
北京的雾霾天 2004-12-07
  • 打赏
  • 举报
回复
不过,你可以这样做:

MSDN:

替换 Continue 语句
Visual Basic .NET 不支持 Visual Basic 早期版本中的 Continue 语句。但可以通过在 Loop 语句上添加语句标签,并从循环中分支到该语句来实现相同的功能:

Dim LoopCounter As Integer = 0
Do While LoopCounter < 100
LoopCounter += 1
Dim SkipToNextIteration As Boolean ' Local to this loop.
' Processing, which might change value of SkipToNextIteration.
If SkipToNextIteration = True Then GoTo EndOfLoop
' More processing if SkipToNextIteration was still False.
EndOfLoop: Loop ' Acts like Continue.
flame_qin 2004-12-07
  • 打赏
  • 举报
回复
break
北京的雾霾天 2004-12-07
  • 打赏
  • 举报
回复
可以看一下不同语言中的关键字的比较:

不同语言中的关键字的比较
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vsintro7/html/vxorilanguageequivalentskeywords.asp
北京的雾霾天 2004-12-07
  • 打赏
  • 举报
回复
呵呵,在VB里不能用Continue的,具体的情况可能有不同的处理方式.便是在VB里没有这么一个关键字的.
haoztao 2004-12-07
  • 打赏
  • 举报
回复
你要是硬要那么实现应该是不可能的,只有
while (i=5 or j=1)

if j <>0
pf()
end if
i++
end while
haoztao 2004-12-07
  • 打赏
  • 举报
回复
你要是硬要那么实现应该是不可能的,只有
while (i=5 or j=1)

if j <>0
pf()
end if
i++
end while
wangtao301301 2004-12-07
  • 打赏
  • 举报
回复
方法一:用continue
方法二:
while (i=5 or j=1)

if j <>0
pf()
end if
i++
end while
lin_lin 2004-12-07
  • 打赏
  • 举报
回复
continue
allanli 2004-12-07
  • 打赏
  • 举报
回复
VB.NET 现在版本还没有continue语句,要等2005才有,所以只能通过
if 语句实现了,只需要换个思维就可以啦

while (i=5 or j=1)

if j<>0 '当j<>0 时才进入循环,执行pf函数,
pf()
i++
end if
end while
Layto 2004-12-07
  • 打赏
  • 举报
回复
Exit Select
Exit Try
Exit Do
Exit While
Exit For
morefish 2004-12-07
  • 打赏
  • 举报
回复
continue
landlordh 2004-12-07
  • 打赏
  • 举报
回复
退出当前循环,进行下一次循环?

exit while会退出while,但是不会继续循环

你另外写,才可以达到你的效果
chenhaohf 2004-12-07
  • 打赏
  • 举报
回复
exit while

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧