在VBA中调用子 [英] Calling a Sub in VBA
问题描述
这是我的简化脚本:
Sub SomeOtherSub(Stattyp As String)
'Daty and the other variables are defined here
CatSubProduktAreakum(Stattyp, Daty + UBound(SubCategories) + 2)
End Sub
Sub CatSubProduktAreakum(Stattyp As String, starty As Integer)
'some stuff
End Sub
CatSubProduktAreakum的调用被标记为红色语法错误。我不明白这个错误。这是带有两个参数的简单子例程调用。 VBA为什么不接受呼叫?
The call of CatSubProduktAreakum is marked red as a "syntax error". I don't understand the error. It is a simple sub-routine call with two arguments. Why does VBA not accept the call?
推荐答案
尝试-
Call CatSubProduktAreakum(Stattyp, Daty + UBound(SubCategories) + 2)
As for the reason, this from MSDN via this question - What does the Call keyword do in VB6?
在调用过程时不需要使用Call关键字。
但是,如果使用Call关键字调用需要
参数的过程,则必须将参数列表括在括号中。如果省略
的Call关键字,则还必须省略
参数列表的括号。如果您使用Call语法来调用任何内部函数或
用户定义的函数,则该函数的返回值将被舍弃。
You are not required to use the Call keyword when calling a procedure. However, if you use the Call keyword to call a procedure that requires arguments, argumentlist must be enclosed in parentheses. If you omit the Call keyword, you also must omit the parentheses around argumentlist. If you use either Call syntax to call any intrinsic or user-defined function, the function's return value is discarded.
这篇关于在VBA中调用子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!