Imports System
Imports System.Reflection
Public Class OptionalArg
Public Sub MyMethod(ByVal a As Integer,Optional ByVal b As Double = 1.2,Optional ByVal c As Integer = 1)
Console.WriteLine("a = " & a & " b = " & b & " c = " & c)
End Sub
End Class
Class Example
Public Shared Sub Main()
Dim o As New OptionalArg()
Dim t As Type
t = GetType(OptionalArg)
Dim bf As BindingFlags = BindingFlags.Public Or BindingFlags.Instance Or BindingFlags.InvokeMethod Or BindingFlags.OptionalParamBinding
t.InvokeMember("MyMethod", bf, Nothing, o, New Object() {10, 5.3, 12})
t.InvokeMember("MyMethod", bf, Nothing, o, New Object() {10, Type.Missing, Type.Missing})
End Sub
End Class