2

In an IDL, I define a method:

[id(1), helpstring("BLAH")] HRESULT SomeMethod([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.

lycoan
  • 23
  • 4

1 Answers1

-1

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.

JimmyPena
  • 8,694
  • 6
  • 43
  • 64