2

Converting some VB.NET code. Some of the static functions do some work on some parameters passed by reference, but does not return anything. What exactly is going on in the VB.NET functions that they can exist without having a return value and not get any debug errors? What happens to the boolean?

Overloads Shared Function ExampleMethod(ByRef buffer1() as Byte, ByRef buffer2() as Byte) As Boolean
'do stuff here, no return types
End Function

Overloads Shared Function ExampleMethod(ByRef buffer1() as Byte, ByRef buffer2 as Byte) As Boolean
'do stuff here, no return types
End Function
1

1 Answer 1

3

See https://msdn.microsoft.com/en-us/library/sect4ck6.aspx

With VB.Net you can return a value by either using the Return statement, or assigning a value to the Function Name, e.g.:

    ExampleMethod = true
    Exit Function
End Function

It goes on to say:

If you use Exit Function without assigning a value to name, the procedure returns the default value for the data type that's specified in returntype. If returntype isn't specified, the procedure returns Nothing, which is the default value for Object.

C# is a bit more strict!

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

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.