在函数上使用子例程的目的 [英] Purpose of using sub routines over functions

查看:31
本文介绍了在函数上使用子例程的目的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Access 已经有一段时间了,虽然我理解 Function 比 Sub 的明显好处,但是它可以返回值作为结果,我不确定为什么我应该使用函数上的子函数.毕竟除非我弄错了;函数可以做 Subs 可以做的一切吗?

I've been working with Access for a while now, and although I understand the obvious benefit of a Function over a Sub, been that it can return values as a result, I'm not sure as to why I should use a Sub over a Function. After all unless I'm mistaken; Functions can do everything Subs can do?

注意:我完全了解如何使用 Sub 和 Function,所以我不想解释它们是如何工作的.

Note: I'm fully aware of how to use both Sub's and Function's so not looking for an explanation of how they work.

推荐答案

主要区别不只是返回值,似乎 subs 比函数更快(至少在 .net 中)因为当没有返回值时 subs 的 MSIL 代码要短得多.所以当没有返回值时,整体潜艇会更快.哦,我刚刚找到了一个很好的来源(谈论 .net),也许您想进一步了解它 - 函数与子程序

The main difference is not only the return value, it seems that subs are faster than functions (at least in .net) because the MSIL code of subs is much shorter when no value is returned. so overall subs are faster when no value is returned. oh i've just found a great source for it (talks about .net), maybe you would like to read further about it- Functions vs. Subroutines

这篇关于在函数上使用子例程的目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆