Sub StoreQA(ShapeClicked As Shape)
MsgBox "yeee"
End Sub
Sub ThisIsToBeRun()
StoreQA
End Sub
I get Compile Error: Argument not optional.
I tried mentioning StoreQA(ShapeClicked As Shape)
but that didn't help either.
Sub StoreQA(ShapeClicked As Shape)
MsgBox "yeee"
End Sub
Sub ThisIsToBeRun()
StoreQA
End Sub
I get Compile Error: Argument not optional.
I tried mentioning StoreQA(ShapeClicked As Shape)
but that didn't help either.
You are defining a parameter here, named
ShapeClicked
:Because the parameter isn't
Optional
, an argument must be provided for this parameter by any code that means to invoke thisStoreQA
procedure:如果不需要该参数,请将其删除:
If it's needed in some places but not in others, consider making it
Optional
:然后,您可以合法地调用该过程而无需提供任何参数:
可选注意事项
If the
StoreQA
procedure receives anOptional
parameter, it needs to verify whether it received a valid object reference before using it - otherwise expect problems:If
Optional
parameters are declaredAs Variant
(explicitly or not), then you can use theIsMissing
function to verify whether an optional parameter was supplied - useful whenNothing
is also a valid, useful value to receive (for object references anyway - for plain value types it can remove the need to resort magic/hard-coded "invalid" values):