Camper Camper - 9 months ago 57 Question

Returning/Chaining variables

Id like to have VB.Net code written like this.,parameters)
">> Passing parameters to module2 >>",parameters)

Essentially passing parameters between modules without running a module via a return statement, or multiple statements in this case. And avoiding shared public registers. Is this even possible? Can I pass variables in the module header maybe?



Create a class MyParameters

Public Class MyParameters
    'Add any inputs / outputs
    Public AnInput As Integer
    Public AnOutput As String
End Class

Define Module1.Run as

Public Sub Run(ByVal args As MyParameters)
    args.AnOutput = String.Format("The user passed {0}", args.AnInput)
End Sub

Define 'Module2.Run' as

Public Sub Run(ByVal args As MyParameters)
End Sub

Then you can call with:

Public Sub Main()
    Dim args = New MyParameters() With {.AnInput = 5}
End Sub