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
3 Answers
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
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.