返回vs退出子 [英] Return vs Exit Sub
本文介绍了返回vs退出子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Return和Exit Sub之间有什么区别吗?
我有一些代码在我的Sub中出错时使用两者。
谢谢,
Tom
解决方案
你好tshad,
IL输出与返回没有区别。和退出子当
用于子时。但是,为了便于阅读,我建议使用Exit Sub。
返回表示将一个值推回给调用者,因为一个子元素没有
有一个返回值,不太明确的意图。
-Boo
返回和退出Sub之间有什么区别吗?
我有一些代码,当我在Sub中出错时使用这两个代码。
谢谢,
Tom
Tshad,
虽然我更喜欢Exit Sub,但应该没有任何区别。 />
Cor
" tshad" < ts ********** @ ftsolutions.comschreef在bericht
news:uR ************** @ TK2MSFTNGP05.phx.gbl ...
返回和退出Sub之间有什么区别吗?
我有一些代码,当我使用时在我的Sub中有错误。
谢谢,
Tom
" GhostInAK" < gh ******* @ gmail.comschrieb:
> IL输出与返回没有区别。和退出子
用于子时。但是,为了便于阅读,我建议使用Exit Sub。
Return表示将值推回给调用者,因为子不具有返回值,因此意图不太明确。
嗯,你可以将''Return''解释为Return something。或者返回
到某物。
-
MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http://classicvb.org/petition/>
>
Is there any difference between Return and Exit Sub?
I have some code that uses both when I have an error in my Sub.
Thanks,
Tom
解决方案
Hello tshad,
There is no difference in the IL output from "Return" and "Exit Sub" when
used in a sub. However, for readability I would suggtest using Exit Sub.
Return denotes pushing a value back to the caller, which since a sub doesnt
have a return value, makes for a less clear intent.
-Boo
Is there any difference between Return and Exit Sub?
I have some code that uses both when I have an error in my Sub.
Thanks,
Tom
Tshad,
There should be not any difference although I prefer Exit Sub.
Cor
"tshad" <ts**********@ftsolutions.comschreef in bericht
news:uR**************@TK2MSFTNGP05.phx.gbl...Is there any difference between Return and Exit Sub?
I have some code that uses both when I have an error in my Sub.
Thanks,
Tom
"GhostInAK" <gh*******@gmail.comschrieb:>There is no difference in the IL output from "Return" and "Exit Sub" when
used in a sub. However, for readability I would suggtest using Exit Sub.
Return denotes pushing a value back to the caller, which since a sub doesnt
have a return value, makes for a less clear intent.Well, you could interpret ''Return'' either as "Return something" or "Return
to something".
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
这篇关于返回vs退出子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文