开发者

How to set IDL, so users can tell a parameter is "optional" in VBA?

开发者 https://www.devze.com 2023-03-31 08:05 出处:网络
In an IDL, I define a method: [id(1), helpstring(\"BLAH\")] HRESULT SomeMeth开发者_如何学Pythonod([in, optional, defaultvalue(NULL)] IDispatch* para);

In an IDL, I define a method:

[id(1), helpstring("BLAH")] HRESULT SomeMeth开发者_如何学Pythonod([in, optional, defaultvalue(NULL)] IDispatch* para);

When I use this method in VBA, the screen tip only shows:

SomeMethod([para As Object])

What I want is that, there's some indication saying this parameter is "optional", or at least say there is a default parameter "NULL". Like this:

SomeMethod([[optional]para As Object])

or at least

SomeMethod([para As Object = NULL])

Anyone can help? Thanks.


In VBA, optional parameters are in brackets. i.e.

MsgBox(prompt[, buttons] [, title] [, helpfile, context])

buttons, title, helpfile and context are all optional arguments for the MsgBox Function.

The brackets are the indicator that a parameter is optional. There is no other indicator.

As a workaround, you could add "optional_" to the beginning of variables that you want to display as optional. ex:

Function DoSomething(Optional optional_Value As String) As String

Now you can see in the Intellisense the word "optional_" as part of the variable name.

0

精彩评论

暂无评论...
验证码 换一张
取 消