2

Is it possible to create a VB function with multiple outputs. Note: I am not looking for an array containing me three outputs or a variable using delimitters

0

3 Answers 3

2

Sure, pass your parameters to the function by reference (byref) you can then modify them in the body of the function.

Sign up to request clarification or add additional context in comments.

Comments

2

If you're running .NET4 then you could use one of the new Tuple types (eg, Tuple(Of T1, T2)):

Public Function ReturnTwoValues() As Tuple(Of String, Integer)
    Return Tuple.Create("Test", 42)
End Function

Comments

0

C# has the out keyword:

void TestFunc(int x, ref int y, out int z) {
  x++;  
  y++;
  z = 5;
}

VB has no equivalent as explicit. You can only pass values using ByRef:

Sub TestFunc(ByVal x As Integer, ByRef y As Integer, ByRef z As Integer)
  x += 1
  y += 1 
  z = 5 
End Sub

Details of VB/C# differences here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.