多个参数Subs vba [英] multiple argument subs vba

查看:106
本文介绍了多个参数Subs vba的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将VBA与Access 2010结合使用时,我会看到以下内容:

Using VBA with Access 2010, I have a sub:

Public Sub setInterest(account As String, dmonth As Integer)
    ...somecode...
End Sub

我打电话给

setInterest("myAccount",3)

我得到语法错误.
将sub修改为仅包含一个参数,而忽略3个则不会出错,问题只在于当我有2个参数时.

And I get syntax errors.
Modifying the sub to only take one argument and leaving out the 3 gives no errors, the problem is only when I have 2 arguments.

推荐答案

使用多个参数时,您可以编写:

When using multiple arguments, you can either write:

 setInterest "myAccount", 3

 Call setInterest("myAccount", 3)

在两个示例中,您都可以命名参数:

In both examples you can name the arguments:

setInterest account:="myAccount", dmonth:= 3

这篇关于多个参数Subs vba的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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