The CallByName
function[
^] exists purely for background-compatibility with VB6. It can only call members on an instance of a class; it cannot call
Shared
members - which is what all members of a module are - because VB6 didn't have such members.
You're going to need to use reflection instead, which is what
CallByName
uses behind the scenes:
Reflection - Visual Basic | Microsoft Learn[
^]
Eg:
Dim moduleType As Type = Type.GetType(finance)
If moduleType Is Nothing Then Throw New InvalidOperationException("Module '" + finance + "' not found.")
Dim methodInfo As MethodInfo = moduleType.GetMethod("Process", BindingFlags.Public Or BindingFlags.Static)
If methodInfo Is Nothing Then Throw New InvalidOperationException("Module '" + moduleType + "' does not contain a method called Process.")
methodInfo.Invoke(Nothing, Array.Empty(Of Object)())