Home > OS >  Making a function with mutually exclusive pre defined argument list
Making a function with mutually exclusive pre defined argument list

Time:08-20

I know what an optional argument list is and how to set default vales.

Public Function argTest(arg1 As String, Optional arg2 As String = "TEST", Optional arg3 As String = "TEST") As Long
'Some logic and stuff
End Function

But thats not exactly what I'm after. Here is an example

If you add the UIAutomationClient reference and paste the following code into a sub

Dim uiElement As IUIAutomationElement
Dim uiProp As IUIAutomationCondition
    
uiElement.FindFirst(TreeScope_Children, uiProp) = 0

Where you define the TreeScope_Children is the functionality I'm after. right after typing "uiElement.FindFirst(" you get a drop down menu of options.

How do I make a function call do THAT?

CodePudding user response:

Using an enumeration:

Enum Foo
   bar = 1
   baz = 2
End Enum

Public Function argTest(grr As Foo)

End Function

CodePudding user response:

If you want to create a method parameter which references an existing enum from a library referenced by your VBA project, you can do it like this:

enter image description here

  • Related