Camper Camper - 1 year ago 95 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?


Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download