Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual Basic
Error Messages
Compiler Messages
 Function '<procedurename>' doesn't ...
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual Basic Reference: Error Messages 
Function '<procedurename>' doesn't return a value on all code paths 

Error Message

Function '<procedurename>' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.

A Function procedure has at least one possible path through its code that does not return a value.

You can return a value from a Function procedure in any of the following ways:

  • Assign the value to the Function procedure name and then perform an Exit Function statement.

  • Assign the value to the Function procedure name and then perform the End Function statement.

  • Include the value in a Return Statement (Visual Basic).

If control passes to Exit Function or End Function and you have not assigned any value to the procedure name, the procedure returns the default value of the return data type. For more information, see "Behavior" in Function Statement (Visual Basic).

By default, this message is a warning. For more information on hiding warnings or treating warnings as errors, see Configuring Warnings in Visual Basic.

Error ID: BC42105

To correct this error

  • Check your control flow logic and make sure you assign a value before every statement that causes a return.

    It is easier to guarantee that every return from the procedure returns a value if you always use the Return statement. If you do this, the last statement before End Function should be a Return statement.

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker